Skip to content

Commit e64d94e

Browse files
authored
Add auto-merge workflow for trusted PRs
1 parent 857dc2d commit e64d94e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/auto-merge.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Auto Merge Trusted PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
enable-auto-merge:
13+
runs-on: ubuntu-latest
14+
# Check if the PR author is a Bot OR has high privileges (Owner, Admin, Maintainer)
15+
if: |
16+
github.event.pull_request.user.type == 'Bot' ||
17+
contains(fromJSON('["OWNER", "ADMIN", "MAINTAINER", "COLLABORATOR"]'), github.event.pull_request.author_association)
18+
steps:
19+
- name: Enable Auto-Merge for PR
20+
env:
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
PR_URL: ${{ github.event.pull_request.html_url }}
23+
# Logic:
24+
# --auto: Queues the merge to happen only after requirements (tests/checks) are met.
25+
# --squash: Squashes commits into one (cleaner history). Change to --merge or --rebase if preferred.
26+
run: |
27+
echo "Processing PR: $PR_URL"
28+
echo "Author Association: ${{ github.event.pull_request.author_association }}"
29+
30+
gh pr merge "$PR_URL" --auto --squash

0 commit comments

Comments
 (0)