Make web and commit #82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Make web and commit | |
on: | |
workflow_dispatch: | |
workflow_call: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
tcw_commit_hash: ${{ steps.get_tcw_commit_hash.outputs.tcw_commit_hash }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Debug - List all branches in parent and submodule | |
run: | | |
echo "Listing branches in parent repository:" | |
git branch -a | |
echo "Listing branches in teddycloud_web submodule:" | |
cd teddycloud_web | |
git branch -a | |
cd .. | |
- name: Checkout the same branch for teddycloud_web | |
run: | | |
# Get the current branch of the parent project | |
PARENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
# Navigate into the submodule directory | |
cd teddycloud_web | |
# Fetch all branches from the remote in case it's not already available | |
git fetch origin | |
echo "Listing branches in teddycloud_web submodule:" | |
git branch -a | |
# Fetch the specific branch from the remote if it doesn't exist locally | |
if git show-ref --verify --quiet refs/heads/$PARENT_BRANCH; then | |
git checkout $PARENT_BRANCH | |
else | |
# Check if the branch exists on the remote and fetch it | |
if git ls-remote --heads origin $PARENT_BRANCH | grep -q $PARENT_BRANCH; then | |
git fetch origin $PARENT_BRANCH:$PARENT_BRANCH | |
git checkout $PARENT_BRANCH | |
else | |
echo "Branch '$PARENT_BRANCH' does not exist in the submodule. Exiting." | |
exit 1 | |
fi | |
fi | |
# Navigate back to the parent directory | |
cd .. | |
- name: Git status | |
run: | | |
git status | |
git submodule status | |
cd teddycloud_web | |
git status | |
cd .. | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.11.1" | |
- name: Install NPM version | |
run: npm install -g npm@10.8.2 | |
- name: Disable CI checks | |
run: echo "CI=false" >> $GITHUB_ENV | |
- name: Make Web | |
run: make web | |
- name: Configure Git | |
run: | | |
git config --global user.email "scilor@users.noreply.github.com" | |
git config --global user.name "SciLor" | |
- name: Commit and push if changed | |
run: | | |
if [[ -n $(git status --porcelain) ]]; then | |
git add . | |
git commit -m "Update frontend (make web)" | |
git pull --rebase | |
git push | |
else | |
echo "No changes to commit and push." | |
fi | |
- name: Get Last Commit Hash | |
id: get_tcw_commit_hash | |
run: echo "tcw_commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Wait for a few seconds # to avoid missing commit in followup steps | |
run: sleep 30 | |
build_docker: | |
needs: build | |
uses: ./.github/workflows/publish_docker_matrix_all.yml | |
with: | |
tcw_commit_hash: ${{ needs.build.outputs.tcw_commit_hash }} |