|
1 | 1 | name: Dependabot auto-merge |
2 | 2 |
|
3 | | -"on": |
4 | | - pull_request: |
5 | | - types: |
6 | | - - opened |
7 | | - - synchronize |
8 | | - - reopened |
| 3 | +# Hardened against the CVE-2025-61671 pattern (and similar): |
| 4 | +# * Trust the PR author via `github.event.pull_request.user.login` only as a |
| 5 | +# coarse gate. The actual security boundary is the official |
| 6 | +# dependabot/fetch-metadata action, which signs over the PR contents and |
| 7 | +# exposes update-type / dependency metadata in a tamper-resistant way. |
| 8 | +# * Only `version-update:semver-patch` and `version-update:semver-security` |
| 9 | +# are eligible for `--merge`. Minor and major bumps get `--approve` only; |
| 10 | +# a human must hit the merge button. |
| 11 | +# * `gh pr merge --auto --squash` lets GitHub gate the actual merge on the |
| 12 | +# repository's required status checks (configured via branch protection), |
| 13 | +# so we do NOT need to wait for CI inside this workflow. |
| 14 | + |
| 15 | +'on': |
| 16 | + pull_request_target: |
| 17 | + types: [opened, synchronize, reopened] |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
9 | 22 |
|
10 | 23 | jobs: |
11 | 24 | automerge: |
12 | 25 | runs-on: ubuntu-latest |
13 | | - if: github.actor == 'dependabot[bot]' |
14 | | - permissions: |
15 | | - contents: write |
16 | | - pull-requests: write |
| 26 | + if: github.event.pull_request.user.login == 'dependabot[bot]' |
17 | 27 | steps: |
18 | | - - name: Enable auto-merge for Dependabot PRs |
19 | | - run: gh pr merge --auto --squash "$PR_URL" |
| 28 | + - name: Fetch Dependabot metadata |
| 29 | + id: meta |
| 30 | + uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0 |
| 31 | + with: |
| 32 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + |
| 34 | + - name: Approve PR (all update types) |
20 | 35 | env: |
21 | 36 | PR_URL: ${{ github.event.pull_request.html_url }} |
22 | 37 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + run: gh pr review --approve "$PR_URL" |
| 39 | + |
| 40 | + - name: Enable auto-merge (patch + security only) |
| 41 | + if: | |
| 42 | + steps.meta.outputs.update-type == 'version-update:semver-patch' || |
| 43 | + steps.meta.outputs.update-type == 'version-update:semver-security' |
| 44 | + env: |
| 45 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 46 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + run: gh pr merge --auto --squash "$PR_URL" |
0 commit comments