mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
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>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
name: PR Approval Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, ready_for_review]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-approvals:
|
||||
runs-on: ubuntu-latest
|
||||
# Skip this check if PR is in draft state
|
||||
if: github.event.pull_request.draft == false
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check PR approvals
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Check if PR author is clockwork-labs-bot
|
||||
if [[ "${{ github.event.pull_request.user.login }}" != "clockwork-labs-bot" ]]; then
|
||||
echo "PR opened by ${{ github.event.pull_request.user.login }}, not clockwork-labs-bot. Skipping check."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PR_NUMBER="${{ github.event.pull_request.number }}"
|
||||
# Get approval count
|
||||
APPROVALS=$(gh pr view $PR_NUMBER --json reviews -q '.reviews | map(select(.state == "APPROVED")) | length')
|
||||
|
||||
echo "PR has $APPROVALS approvals"
|
||||
|
||||
if [[ $APPROVALS -lt 2 ]]; then
|
||||
echo "Error: PRs from clockwork-labs-bot require at least 2 approvals"
|
||||
exit 1
|
||||
else
|
||||
echo "PR has the required number of approvals"
|
||||
fi
|
||||
Reference in New Issue
Block a user