Skip to content

Commit

Permalink
Fix approval count workflow
Browse files Browse the repository at this point in the history
When queried from within action context .authorAssociation is not
filled in as MEMBER but CONTRIBUTOR instead so adjust to query to
take that into account.
  • Loading branch information
svenklemm committed Oct 19, 2024
1 parent 694fcf4 commit 5945e01
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/pr-approvals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
name: PR Approval Check
"on":
pull_request:
types: [opened, synchronize, reopened, edited, auto_merge_enabled, auto_merge_disabled]
branches: [main]
jobs:

Expand All @@ -27,9 +28,7 @@ jobs:
# Get the list of modified files in this pull request
files=$(gh pr view $PR_NUMBER --json files --jq '.files.[].path | select(startswith(".github") | not)')
# Get the number of approvals in this pull request
approvals=$(gh pr view $PR_NUMBER --json reviews --jq '[.reviews.[] | select(.authorAssociation == "MEMBER" and .state == "APPROVED")] | length')
gh pr view $PR_NUMBER --json reviews --jq '[.reviews.[] | select(.authorAssociation == "MEMBER" and .state == "APPROVED")]'
approvals=$(gh pr view $PR_NUMBER --json reviews --jq '[.reviews.[] | select((.authorAssociation == "MEMBER" or .authorAssociation == "CONTRIBUTOR") and .state == "APPROVED")] | length')
if [[ $approvals -lt 2 ]] && [[ "${files}" ]] ; then
echo "This pull request requires 2 approvals before merging."
Expand Down

0 comments on commit 5945e01

Please sign in to comment.