File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,20 +29,18 @@ jobs:
2929 echo "Expected Code Reviewer: $CODE_REVIEWER"
3030
3131 # -- 2. Check the review status
32- CR_APPROVED=$(gh pr view -R "$REPO" "$PR_NUMBER" --json "reviews" |
33- jq -r --arg cr "$CODE_REVIEWER" ' .reviews[] |
34- select((.author.login == $cr) and .state == "APPROVED") |
35- .state')
32+ reviews=$(gh pr view -R "$REPO" "$PR_NUMBER" --json "reviews" | jq -r --arg cr "$CODE_REVIEWER" '
33+ [ .reviews[] | select(.author.login == $cr) ]')
3634
37- if [[ "$CR_APPROVED" == "APPROVED" ]]; then
35+ # Check if any review is APPROVED
36+ approved=$(echo "$reviews" | jq -r '[ .[] | select(.state == "APPROVED") ] | length')
37+
38+ if [[ "$approved" -gt 0 ]]; then
3839 echo "✅ Success: The listed Code Reviewer ($CODE_REVIEWER) has approved this PR."
3940 else
40- # Exit with failure if the specific reviewer has not yet approved
4141 echo "::error::The listed Code Reviewer ($CODE_REVIEWER) has not yet approved this PR."
4242 echo "Current reviews for this user:"
43- gh pr view -R "$REPO" "$PR_NUMBER" --json "reviews" | jq -r --arg cr "$CODE_REVIEWER" '
44- .reviews[] | select(.author.login == $cr) | "- \(.state)"'
45-
43+ echo "$reviews" | jq -r '.[] | "- \(.state)"'
4644 echo "::notice::This action may be bypassed by a reviewer with sufficient permissions if appropriate."
4745 exit 1
4846 fi
You can’t perform that action at this time.
0 commit comments