generated from ExpTechTW/Example
-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (46 loc) · 1.35 KB
/
pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Auto Merge PR
on:
pull_request:
types:
- opened
- synchronize
- labeled
- ready_for_review
- reopened
jobs:
auto-merge:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Debug GitHub Context
run: |
echo "GitHub Event Context:"
echo "${{ toJson(github.event) }}"
- name: Verify PR Author
run: |
AUTHOR=${{ github.event.pull_request.user.login }}
echo "PR Author: $AUTHOR"
if [[ "$AUTHOR" != "whes1015" ]]; then
echo "PR author is not whes1015. Exiting."
exit 1
fi
- name: Checkout PR Branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set PR Number
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
if [[ -z "$PR_NUMBER" ]]; then
echo "Error: Pull request number is empty!"
exit 1
fi
echo "PR Number: $PR_NUMBER"
- name: Auto merge pull request
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
gh pr merge $PR_NUMBER --merge --auto --delete-branch || echo "Auto merge failed for PR #$PR_NUMBER"
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}