Update Submodules #26
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: | |
| # 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: Create Pull Request | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| BRANCH_NAME="update-submodules-$(date +%Y%m%d-%H%M%S)" | |
| git checkout -b $BRANCH_NAME | |
| git add . | |
| SUBMODULE_CHANGES=$(git diff --cached --submodule=short) | |
| git commit -m "🔄 | auto-update submodules to latest commits | |
| ${SUBMODULE_CHANGES}" | |
| git push origin $BRANCH_NAME | |
| gh pr create \ | |
| --title "🔄 | auto-update submodules to latest commits" \ | |
| --body "This PR updates submodules to their latest commits. | |
| ## Changes | |
| \`\`\` | |
| ${SUBMODULE_CHANGES} | |
| \`\`\` | |
| This PR was automatically created by the Update Submodules workflow." \ | |
| --base main \ | |
| --head $BRANCH_NAME \ | |
| --label "dependencies" \ | |
| --label "automated" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create summary | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| echo "## Pull Request Created ❕❕" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "A pull request has been created to update submodules." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Changes:" >> $GITHUB_STEP_SUMMARY | |
| git log -1 --pretty=format:"- Commit: %h%n- Message: %s%n- Author: %an%n- Date: %ad" --date=short >> $GITHUB_STEP_SUMMARY |