-
Notifications
You must be signed in to change notification settings - Fork 7
46 lines (39 loc) · 1.52 KB
/
auto_approve.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
name: Auto Pull Request Approval
on:
pull_request:
types: [opened, synchronize]
paths:
- 'modifier/**'
- 'data/**'
- 'changelogs/**'
jobs:
auto-approve-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: main
- name: Check username
id: check_user
run: |
AUTHOR="${{ github.event.pull_request.user.login }}"
ALLOWED_USERS="EternityTQ, Cre-epbee, tankofpacer"
echo "ALLOWED=false" >> $GITHUB_ENV
if [[ $ALLOWED_USERS =~ (^|[[:space:]])$AUTHOR($|[[:space:]]) ]]; then
echo "ALLOWED=true" >> $GITHUB_ENV
fi
- name: Auto approve pull request
if: env.ALLOWED == 'true'
run: |
curl -X POST -H "Authorization: token ${{ secrets.NORI_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
-d '{"event":"APPROVE"}'
- name: Merge pull request
if: env.ALLOWED == 'true'
run: |
curl -X PUT -H "Authorization: token ${{ secrets.NORI_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge \
-d '{"commit_title":"Automatically merged by GitHub Actions","commit_message":"Merging approved changes","merge_method":"merge"}'