Skip to content

Commit fab6cfc

Browse files
authored
Create pr-review.yml
Signed-off-by: CanbiZ <[email protected]>
1 parent a95fc2d commit fab6cfc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/pr-review.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Pull Request Review Enforcement
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
enforce-review-requirements:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Check out the code
13+
uses: actions/checkout@v2
14+
15+
- name: Verify Reviewer Approvals
16+
id: review-check
17+
run: |
18+
reviews=$(gh api repos/$GITHUB_REPOSITORY/pulls/$GITHUB_EVENT_NUMBER/reviews --jq '[.[] | select(.state == "APPROVED") | .user.login] | unique | length')
19+
if [ "$reviews" -lt 2 ]; then
20+
echo "PR requires at least 2 approvals from the Contributor team."
21+
exit 1
22+
fi
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Confirm Ready to Merge
27+
if: ${{ steps.review-check.outputs.reviews == '2' }}
28+
run: echo "PR is ready to be merged."

0 commit comments

Comments
 (0)