-
Notifications
You must be signed in to change notification settings - Fork 49
33 lines (27 loc) · 952 Bytes
/
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
name: approve
on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened]
jobs:
approve:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Get PR Approvals
run: |
PR_NUMBER=$(jq --raw-output .number "$GITHUB_EVENT_PATH")
APPROVERS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" \
| jq -r '.[] | select(.state == "APPROVED") | .user.login')
echo "APPROVERS=$APPROVERS" >> $GITHUB_ENV
- name: Check for Specific Approver
run: |
SPECIFIC_APPROVER="aoyulong"
if echo "$APPROVERS" | grep -q "$SPECIFIC_APPROVER"; then
echo "Specific approver has approved the PR."
else
echo "The PR has not been approved by the specific approver."
exit 1
fi