Skip to content

Commit 58fbb44

Browse files
committed
Auto-merge Dependabot PRs
1 parent a417556 commit 58fbb44

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Auto-merge Dependabot PRs
2+
3+
# Specify which events trigger this workflow
4+
on:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- reopened
10+
check_suite:
11+
types:
12+
- completed
13+
14+
# Restrict permissions to what is needed
15+
permissions:
16+
pull-requests: write
17+
statuses: read
18+
19+
jobs:
20+
auto-merge:
21+
runs-on: ubuntu-latest
22+
if: |
23+
github.event.pull_request.user.login == 'dependabot[bot]' ||
24+
github.event.pull_request.user.login == 'dependabot-preview[bot]'
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v3
31+
32+
- name: Check if all checks passed
33+
run: |
34+
if [[ -z "${{ github.event.check_suite.conclusion }}" || "${{ github.event.check_suite.conclusion }}" != "success" ]]; then
35+
echo "Checks not successful or invalid state, skipping merge."
36+
exit 0
37+
fi
38+
39+
- name: Auto-merge if checks passed
40+
run: |
41+
gh pr merge ${{ github.event.pull_request.number }} --squash --auto --repo ${{ github.repository }}
42+
43+
- name: Comment on PR if merged
44+
run: |
45+
gh pr comment ${{ github.event.pull_request.number }} --body "This PR has been automatically merged as all checks passed."

0 commit comments

Comments
 (0)