-
Notifications
You must be signed in to change notification settings - Fork 1
34 lines (27 loc) · 1.05 KB
/
auto-review.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
name: 自动批准 PR
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, labeled]
jobs:
auto-approve-and-merge:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Approve and Merge PR if Author is Specified User
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
# 指定允许自动批准和合并的用户名
ALLOWED_USER="github-actions[bot]"
# 检查 PR 作者是否为指定用户
if [[ "${{ github.event.pull_request.user.login }}" == "$ALLOWED_USER" ]]; then
echo "Author is $ALLOWED_USER, approving and merging PR."
# 执行自动批准
gh pr review ${{ github.event.pull_request.number }} --approve
# 执行自动合并并删除分支
gh pr merge ${{ github.event.pull_request.number }} --merge --delete-branch
else
echo "Author is not $ALLOWED_USER, skipping approval and merge."
fi
shell: bash