Skip to content

Commit a1ef1e2

Browse files
authored
ci: add dependabot automerge workflow (#611)
Add workflow to auto-approve and auto-merge Dependabot PRs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents c755601 + 6351ff6 commit a1ef1e2

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Inspired by https://github.com/vercel/turborepo/blob/main/.github/workflows/examples-autoapprove-and-automerge.yml
2+
# Auto-approves and auto-merges Dependabot PRs.
3+
name: Dependabot automerge
4+
on: pull_request
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
dependabot-approve:
12+
runs-on: ubuntu-latest
13+
if: |
14+
always() &&
15+
!contains(needs.*.result, 'failure') &&
16+
!contains(needs.*.result, 'cancelled') &&
17+
github.actor == 'dependabot[bot]'
18+
steps:
19+
- name: Dependabot metadata
20+
id: metadata
21+
uses: dependabot/fetch-metadata@v2
22+
with:
23+
github-token: '${{ secrets.GITHUB_TOKEN }}'
24+
- name: Approve a PR
25+
run: gh pr review --approve "$PR_URL"
26+
env:
27+
PR_URL: ${{github.event.pull_request.html_url}}
28+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
29+
dependabot-merge:
30+
needs: [dependabot-approve]
31+
runs-on: ubuntu-latest
32+
if: github.actor == 'dependabot[bot]'
33+
steps:
34+
- name: Dependabot metadata
35+
id: metadata
36+
uses: dependabot/fetch-metadata@v2
37+
with:
38+
github-token: '${{ secrets.GITHUB_TOKEN }}'
39+
- name: Enable auto-merge for Dependabot PRs
40+
run: gh pr merge --auto --rebase "$PR_URL"
41+
env:
42+
PR_URL: ${{github.event.pull_request.html_url}}
43+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)