Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/check-cr-approved.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,18 @@ jobs:
echo "Expected Code Reviewer: $CODE_REVIEWER"

# -- 2. Check the review status
CR_APPROVED=$(gh pr view -R "$REPO" "$PR_NUMBER" --json "reviews" |
jq -r --arg cr "$CODE_REVIEWER" ' .reviews[] |
select((.author.login == $cr) and .state == "APPROVED") |
.state')
reviews=$(gh pr view -R "$REPO" "$PR_NUMBER" --json "reviews" | jq -r --arg cr "$CODE_REVIEWER" '
[ .reviews[] | select(.author.login == $cr) ]')

if [[ "$CR_APPROVED" == "APPROVED" ]]; then
# Check if any review is APPROVED
approved=$(echo "$reviews" | jq -r '[ .[] | select(.state == "APPROVED") ] | length')

if [[ "$approved" -gt 0 ]]; then
echo "✅ Success: The listed Code Reviewer ($CODE_REVIEWER) has approved this PR."
else
# Exit with failure if the specific reviewer has not yet approved
echo "::error::The listed Code Reviewer ($CODE_REVIEWER) has not yet approved this PR."
echo "Current reviews for this user:"
gh pr view -R "$REPO" "$PR_NUMBER" --json "reviews" | jq -r --arg cr "$CODE_REVIEWER" '
.reviews[] | select(.author.login == $cr) | "- \(.state)"'

echo "$reviews" | jq -r '.[] | "- \(.state)"'
echo "::notice::This action may be bypassed by a reviewer with sufficient permissions if appropriate."
exit 1
fi