Skip to content

Commit b069f1f

Browse files
committed
fix: use pull_request_target and github.token for Dependabot auto-merge
Dependabot-triggered pull_request events only expose a read-only GITHUB_TOKEN and cannot access custom secrets (secrets.GH_TOKEN was empty). Switch to pull_request_target so the workflow runs in the base-branch context where github.token has write permissions.
1 parent c3eeb43 commit b069f1f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/dependabot-auto-merge.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Auto-enable squash merge for Dependabot PRs
22
# GitHub will automatically merge once all required checks pass
3+
#
4+
# Uses pull_request_target so the workflow runs in the base-branch context
5+
# and the default GITHUB_TOKEN has write permissions (Dependabot-triggered
6+
# pull_request events only expose a read-only token).
37
name: Dependabot Auto-merge
48

5-
on: pull_request
9+
on: pull_request_target
610

711
permissions:
812
contents: write
@@ -17,4 +21,4 @@ jobs:
1721
run: gh pr merge --auto --squash "$PR_URL"
1822
env:
1923
PR_URL: ${{ github.event.pull_request.html_url }}
20-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
24+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)