diff --git a/.github/workflows/review-trigger.yml b/.github/workflows/review-trigger.yml index 8b23dd30bb29..7b88260d760c 100644 --- a/.github/workflows/review-trigger.yml +++ b/.github/workflows/review-trigger.yml @@ -1,7 +1,7 @@ -name: Review-Trigger +name: Review-Trigger-TEST on: - pull_request_target: + pull_request: types: - opened - reopened @@ -21,6 +21,28 @@ jobs: - name: Skip merge queue if: ${{ contains(github.ref, 'gh-readonly-queue') }} run: exit 0 + - name: Fail when author pushes new code + # Require new reviews when the author is pushing and he is not a member + if: | + github.event.action == 'synchronize' && + github.event.sender.login == github.event.pull_request.user.login && + github.event.pull_request.author_association != 'MEMBER' + run: | + echo "SENDER: $SENDER ; AUTHOR:$AUTHOR ; ACTION:$ACTION" + echo "::error::Project needs to be reviewed again" + + # We get the list of reviewers who approved the PR + REVIEWERS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.number }}/reviews \ + --jq '{reviewers: [.[] | select(.state == "APPROVED") | .user.login]}') + + # We request them to review again + echo $REVIEWERS | gh api --method POST repos/${{ github.repository }}/pulls/${{ github.event.number }}/requested_reviewers --input - + exit 1 + env: + SENDER: ${{ github.event.sender.login }} + AUTHOR: ${{ github.event.pull_request.author_association }} + ACTION: ${{ github.event.action }} + GH_TOKEN: ${{ github.token }} - name: Get PR number env: PR_NUMBER: ${{ github.event.pull_request.number }}