|
| 1 | +# Nightly job that bumps every git submodule to the latest upstream HEAD |
| 2 | +# and opens (or updates) a PR so the change goes through normal review. |
| 3 | +name: Update submodules |
| 4 | + |
| 5 | +on: |
| 6 | + schedule: |
| 7 | + # 03:00 UTC every day |
| 8 | + - cron: "0 3 * * *" |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + update: |
| 17 | + name: Bump submodules to latest HEAD |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout (no submodules) |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + submodules: false |
| 25 | + # SUBMODULE_UPDATE_PAT: a Personal Access Token (repo + workflow scopes) |
| 26 | + # stored as a repository secret. Without it the GITHUB_TOKEN is used, |
| 27 | + # but pushes made by GITHUB_TOKEN do NOT trigger CI workflows on the |
| 28 | + # resulting PR. Create a PAT at Settings → Developer settings → |
| 29 | + # Personal access tokens and add it at Settings → Secrets → Actions. |
| 30 | + token: ${{ secrets.SUBMODULE_UPDATE_PAT || secrets.GITHUB_TOKEN }} |
| 31 | + |
| 32 | + - name: Update every submodule to remote HEAD |
| 33 | + id: update |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + git submodule sync |
| 37 | + git submodule update --init --remote --depth 1 |
| 38 | +
|
| 39 | + if git diff --quiet HEAD; then |
| 40 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 41 | + else |
| 42 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Push branch and open PR |
| 46 | + if: steps.update.outputs.changed == 'true' |
| 47 | + uses: peter-evans/create-pull-request@v7 |
| 48 | + with: |
| 49 | + token: ${{ secrets.SUBMODULE_UPDATE_PAT || secrets.GITHUB_TOKEN }} |
| 50 | + commit-message: "chore: update submodules to latest HEAD" |
| 51 | + branch: chore/update-submodules |
| 52 | + delete-branch: true |
| 53 | + title: "chore: update submodules to latest HEAD" |
| 54 | + body: | |
| 55 | + Automated nightly submodule update. |
| 56 | +
|
| 57 | + This PR was opened by the **Update submodules** workflow. It bumps |
| 58 | + every registered git submodule to the latest commit on its remote |
| 59 | + default branch. |
| 60 | +
|
| 61 | + Merge when CI passes. |
| 62 | + labels: dependencies |
0 commit comments