Skip to content

Commit 44e599b

Browse files
FBumannclaude
andauthored
ci: auto-approve and auto-merge patch dependabot PRs (#63)
GITHUB_TOKEN can't approve its own PRs when reviews are required. Only auto-merge patch updates, not minor. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5aa24a9 commit 44e599b

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed
Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
name: Dependabot auto-merge
2-
on: pull_request
2+
3+
on:
4+
pull_request:
35

46
permissions:
57
contents: write
68
pull-requests: write
79

810
jobs:
9-
dependabot:
10-
runs-on: ubuntu-latest
11+
auto-merge:
12+
name: Auto-merge patch
1113
if: github.actor == 'dependabot[bot]'
14+
runs-on: ubuntu-24.04
1215
steps:
13-
- name: Dependabot metadata
16+
- uses: dependabot/fetch-metadata@v2
1417
id: metadata
15-
uses: dependabot/fetch-metadata@v2
18+
19+
- name: Generate app token
20+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
21+
id: app-token
22+
uses: actions/create-github-app-token@v2
1623
with:
17-
github-token: "${{ secrets.GITHUB_TOKEN }}"
24+
app-id: ${{ secrets.APP_ID }}
25+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
26+
27+
- name: Approve PR
28+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
29+
run: gh pr review "$PR" --approve
30+
env:
31+
PR: ${{ github.event.pull_request.html_url }}
32+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
1833

19-
- name: Auto-merge minor and patch updates
20-
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
21-
run: gh pr merge --auto --squash "$PR_URL"
34+
- name: Enable auto-merge
35+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
36+
run: gh pr merge "$PR" --auto --squash
2237
env:
23-
PR_URL: ${{ github.event.pull_request.html_url }}
24-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
PR: ${{ github.event.pull_request.html_url }}
39+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)