Update Submodules #505
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: | |
| # Run this workflow every 12 hours | |
| schedule: | |
| # This cron job runs at 00:00 and 12:00 UTC every day | |
| - cron: '0 0,12 * * *' | |
| # Allow manual triggering of the workflow | |
| workflow_dispatch: | |
| inputs: | |
| git_username: | |
| description: 'Git username for commit (optional)' | |
| required: false | |
| default: 'GitHub Submodule Update Bot' | |
| git_email: | |
| description: 'Git email for commit (optional)' | |
| required: false | |
| default: '[email protected]' | |
| jobs: | |
| update-submodules: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # Full write permissions to the repository | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| # Fetch all history for all branches and tags | |
| fetch-depth: 0 | |
| # Fetch submodules (recursive to handle nested submodules) | |
| submodules: recursive | |
| # Use a token with full repository access | |
| token: ${{ secrets.FULL_ACCESS_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name '${{ inputs.git_username || 'GitHub Submodule Update Bot' }}' | |
| git config --global user.email '${{ inputs.git_email || '[email protected]' }}' | |
| - name: Update Submodules | |
| run: | | |
| # Update each submodule to its latest commit on its default branch | |
| git submodule update --remote --recursive | |
| - name: Commit and Push Changes | |
| run: | | |
| # Check if there are any changes | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| # Stage all changes | |
| git add . | |
| # Commit changes | |
| git commit -m "Update submodules to latest versions" | |
| # Push directly to the default branch | |
| git push origin HEAD:${{ github.event.repository.default_branch }} | |
| else | |
| echo "No submodule updates found" | |
| fi |