11name : Dependabot auto-merge
22
3- # Approves and auto-merges Dependabot's patch and minor updates once the required
4- # checks pass. Major bumps are deliberately excluded: they are the ones that break
5- # builds and deserve a human read.
3+ # Enables auto-merge on Dependabot's patch and minor updates. GitHub then merges
4+ # them once the branch protection checks pass — a red build never lands.
65#
7- # Why pull_request_target and not pull_request: GitHub treats Dependabot runs as if
8- # they came from a fork, so on `pull_request` the GITHUB_TOKEN is read-only and
9- # cannot approve or merge. `pull_request_target` runs in the base repository's
10- # context with a writable token.
6+ # Major bumps are deliberately excluded: they are the ones that break builds, and
7+ # they stay open for a human to read.
118#
12- # That trigger is dangerous when a workflow checks out and executes the pull
13- # request's code, because untrusted code would then run with those elevated
14- # permissions. This workflow never checks out the PR — it only reads metadata and
15- # calls the API — so that risk does not apply here.
9+ # No step approves anything. The branch protection on these repositories requires
10+ # passing status checks but not an approving review, so auto-merge is satisfied by
11+ # a green CI alone. That is the point: GitHub documents restricting workflows from
12+ # approving pull requests as a security best practice, and a bot approving its own
13+ # dependency bumps would be oversight in name only.
1614#
17- # Auto-merge waits for the branch protection checks; nothing lands on a red build.
15+ # Why pull_request_target and not pull_request: GitHub treats Dependabot runs as if
16+ # they came from a fork, so on `pull_request` the GITHUB_TOKEN is read-only and
17+ # cannot enable auto-merge. `pull_request_target` runs in the base repository's
18+ # context with a writable token. That trigger is dangerous when a workflow checks
19+ # out and runs the pull request's code, because untrusted code would inherit those
20+ # permissions — this workflow never checks out the PR, it only reads metadata and
21+ # calls the API.
1822
1923on : pull_request_target
2024
@@ -24,8 +28,8 @@ permissions:
2428
2529jobs :
2630 auto-merge :
27- # Verify the author, not just the actor, so the job cannot be driven by a PR
28- # someone else opened.
31+ # Check the author rather than the actor, so the job cannot be driven by a
32+ # pull request someone else opened.
2933 if : github.event.pull_request.user.login == 'dependabot[bot]'
3034 runs-on : ubuntu-latest
3135
@@ -34,18 +38,16 @@ jobs:
3438 id : meta
3539 uses : dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
3640
37- - name : Approve and enable auto-merge for patch and minor updates
41+ - name : Enable auto-merge for patch and minor updates
3842 if : |
3943 steps.meta.outputs.update-type == 'version-update:semver-patch' ||
4044 steps.meta.outputs.update-type == 'version-update:semver-minor'
41- run : |
42- gh pr review --approve "$PR_URL"
43- gh pr merge --auto --squash "$PR_URL"
45+ run : gh pr merge --auto --squash "$PR_URL"
4446 env :
4547 PR_URL : ${{ github.event.pull_request.html_url }}
4648 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4749
48- - name : Flag major updates for manual review
50+ - name : Leave major updates for manual review
4951 if : steps.meta.outputs.update-type == 'version-update:semver-major'
5052 run : |
5153 echo "::notice::Major update (${{ steps.meta.outputs.dependency-names }}) left for manual review."
0 commit comments