Skip to content

Commit

Permalink
Handle no commit update on submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
fl4shforward committed Dec 11, 2024
1 parent 7d7dbc9 commit 8c0e1b9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/update_submodule_to_latest_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,30 @@ jobs:
git pull --rebase origin "$DEFAULT_BRANCH"
SHORT_COMMIT=$(git rev-parse --short HEAD)
echo "latest_tag=$SHORT_COMMIT" >> $GITHUB_ENV
git submodule update --remote --merge
STATUS=$(git status --porcelain)
if [[ -z "$STATUS" ]]; then
echo "No changes detected in submodule. Skipping commit."
echo "submodule_updated=false" >> $GITHUB_ENV
else
echo "Submodule updated. Proceeding with commit."
echo "submodule_updated=true" >> $GITHUB_ENV
fi
cd ..
- name: Commit and push if submodule was updated
if: env.submodule_updated == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ${{ env.submodule_path }}
git commit -m "Update submodule to the latest commit"
git push origin ${{ github.ref_name }}
- name: Trigger Docker build workflow
if: env.submodule_updated == 'true'
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
Expand All @@ -62,5 +77,11 @@ jobs:
}'
- name: Display updated submodule path
if: env.submodule_updated == 'true'
run: |
echo "Submodule updated to the latest commit at path: ${{ env.submodule_path }}"
- name: No update
if: env.submodule_updated == 'false'
run: |
echo "No update for: ${{ env.submodule_path }}"

0 comments on commit 8c0e1b9

Please sign in to comment.