Skip to content

Commit 9472300

Browse files
committed
ci: add auto-merge workflow for dependency PRs
1 parent 610af95 commit 9472300

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Auto-merge dependency PRs
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
auto-merge:
13+
runs-on: ubuntu-latest
14+
if: >-
15+
github.event.pull_request.user.login == 'dependabot[bot]' ||
16+
github.event.pull_request.user.login == 'renovate[bot]'
17+
steps:
18+
- name: Approve PR
19+
env:
20+
PR_URL: ${{ github.event.pull_request.html_url }}
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
run: gh pr review --approve "$PR_URL"
23+
24+
- name: Enable auto-merge
25+
env:
26+
PR_URL: ${{ github.event.pull_request.html_url }}
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
REPO: ${{ github.repository }}
29+
run: |
30+
STRATEGY=$(gh api "repos/$REPO" --jq '
31+
if .allow_squash_merge then "--squash"
32+
elif .allow_merge_commit then "--merge"
33+
elif .allow_rebase_merge then "--rebase"
34+
else "--merge" end')
35+
gh pr merge --auto "$STRATEGY" "$PR_URL"

0 commit comments

Comments
 (0)