diff --git a/.github/workflows/build_commit_web.yml b/.github/workflows/build_commit_web.yml index b84eed7e..2a338b3e 100644 --- a/.github/workflows/build_commit_web.yml +++ b/.github/workflows/build_commit_web.yml @@ -12,18 +12,30 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + - 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) - # Checkout the same branch in the submodule + # Navigate into the submodule directory cd teddycloud_web - git checkout $PARENT_BRANCH || git checkout -b $PARENT_BRANCH - cd .. - - name: Update teddycloud_web submodule - run: git submodule update --remote teddycloud_web + # Fetch all branches from the remote in case it's not already available + git fetch origin + + # Check if the branch exists locally or on the remote + if git show-ref --verify --quiet refs/heads/$PARENT_BRANCH; then + git checkout $PARENT_BRANCH + elif git show-ref --verify --quiet refs/remotes/origin/$PARENT_BRANCH; then + git checkout $PARENT_BRANCH + else + echo "Branch '$PARENT_BRANCH' does not exist in the submodule. Exiting." + exit 1 + fi + + # Navigate back to the parent directory + cd .. - name: Git status run: |