@@ -38,15 +38,29 @@ jobs:
3838 github.event.pull_request.author_association != 'CONTRIBUTOR' &&
3939 github.event.pull_request.author_association != 'MEMBER'
4040 run : |
41- echo "User's association is ${{ github.event.pull_request.author_association }}"
4241 # We get the list of reviewers who approved the PR
4342 REVIEWERS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
4443 --jq '{reviewers: [.[] | select(.state == "APPROVED") | .user.login]}')
4544
46- # We request them to review again
47- echo $REVIEWERS | gh api --method POST repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers --input -
45+ # We request them to review again.
46+ echo $REVIEWERS | gh api --silent -- method POST repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers --input -
4847
49- echo "::error::Project needs to be reviewed again"
48+ APPROVERS=$(echo "$REVIEWERS" | jq -r '.reviewers | map("@" + .) | join(", ")')
49+
50+ tee -a "$GITHUB_STEP_SUMMARY" <<EOF
51+ ## Review required
52+
53+ **What failed:** @${{ github.event.pull_request.user.login }} (association \`${{ github.event.pull_request.author_association }}\`)
54+ pushed \`${{ github.event.pull_request.head.sha }}\` after this pull request was already approved.
55+ An approval only covers the code it was given for, so a push from an author outside the
56+ organisation invalidates it.
57+
58+ **What needs to be done:** review has been re-requested from ${APPROVERS}.
59+ Once a new approval lands, this workflow re-runs and the check passes.
60+ The author does not need to change anything.
61+ EOF
62+
63+ echo "::error title=Review required::Author pushed new commits after approval, a new approval from ${APPROVERS} is needed"
5064 exit 1
5165 env :
5266 GH_TOKEN : ${{ github.token }}
0 commit comments