Update Submodules #18
This file contains hidden or 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: Update Submodules | |
| on: | |
| # Trigger on pushes to main branch | |
| push: | |
| branches: [main] | |
| # Manual trigger | |
| workflow_dispatch: | |
| # Schedule to check for updates daily at 2 AM UTC | |
| schedule: | |
| - cron: '0 2 * * *' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| update-submodules: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| - name: Update submodules | |
| run: | | |
| git submodule foreach --quiet ' | |
| echo "Updating $name ..." | |
| git pull origin $(git rev-parse --abbrev-ref HEAD) | |
| ' | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "No changes detected" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push changes | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git add . | |
| SUBMODULE_CHANGES=$(git diff --cached --submodule=short) | |
| git commit -m "🔄 | auto-update submodules to latest commits | |
| ${SUBMODULE_CHANGES}" | |
| git push | |
| - name: Create summary | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| echo "## Submodules Updated ⬆️" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "The following submodules were updated:" >> $GITHUB_STEP_SUMMARY | |
| git log -1 --pretty=format:"- Commit: %h%n- Message: %s%n- Author: %an%n- Date: %ad" --date=short >> $GITHUB_STEP_SUMMARY |