Skip to content

Commit 41ab8f3

Browse files
authored
CI - clockwork-labs-bot needs 2 approvals (#4568)
# Description of Changes PRs created by `clockwork-labs-bot` require 2 approvals. After merging, we would need to make this check required. # API and ABI breaking changes CI only. # Expected complexity level and risk 1. This is copy-pasted and simplified from another repo that has the same workflow. # Testing None --------- Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent 78c8acd commit 41ab8f3

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: PR Approval Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
pull_request_review:
7+
types: [submitted]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
check-approvals:
14+
runs-on: ubuntu-latest
15+
# Skip this check if PR is in draft state
16+
if: github.event.pull_request.draft == false
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Check PR approvals
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
# Check if PR author is clockwork-labs-bot
29+
if [[ "${{ github.event.pull_request.user.login }}" != "clockwork-labs-bot" ]]; then
30+
echo "PR opened by ${{ github.event.pull_request.user.login }}, not clockwork-labs-bot. Skipping check."
31+
exit 0
32+
fi
33+
34+
PR_NUMBER="${{ github.event.pull_request.number }}"
35+
# Get approval count
36+
APPROVALS=$(gh pr view $PR_NUMBER --json reviews -q '.reviews | map(select(.state == "APPROVED")) | length')
37+
38+
echo "PR has $APPROVALS approvals"
39+
40+
if [[ $APPROVALS -lt 2 ]]; then
41+
echo "Error: PRs from clockwork-labs-bot require at least 2 approvals"
42+
exit 1
43+
else
44+
echo "PR has the required number of approvals"
45+
fi

0 commit comments

Comments
 (0)