Skip to content

Commit

Permalink
modified trigger for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich committed Apr 8, 2024
1 parent 49b2b07 commit 82fe32e
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions .github/workflows/review-trigger.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Review-Trigger
name: Review-Trigger-Test

on:
pull_request_target:
pull_request:
types:
- opened
- reopened
Expand All @@ -14,32 +14,44 @@ on:
jobs:
trigger-review-bot:
# (It is not a draft) && (it is not a review || it is an approving review)
if: ${{ github.event.pull_request.draft != true && (github.event_name != 'pull_request_review' || (github.event.review && github.event.review.state == 'APPROVED')) }}
if: ${{ github.event.pull_request.draft != true }}
runs-on: ubuntu-latest
name: trigger review bot
steps:
- name: Skip merge queue
if: ${{ contains(github.ref, 'gh-readonly-queue') }}
run: exit 0
- name: Fail when author pushes new code
id: fail
# Require new reviews when the author is pushing and he is not a member
if: |
github.event_name == 'pull_request_target' &&
github.event.action == 'synchronize' &&
github.event.sender.login == github.event.pull_request.user.login &&
github.event.pull_request.author_association != 'MEMBER'
github.event.sender.login == github.event.pull_request.user.login
run: |
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 get the users who comment
COMMENTS=$(gh pr view ${{ github.event.number }} --json comments --jq ".comments[].author.login")
echo "commenters=COMMENTS" >> "$GITHUB_OUTPUT"
echo "Commeneters are $COMMENTS"
echo "::error::Project needs to be reviewed again"
# 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:
GH_TOKEN: ${{ github.token }}
# - name: Comment requirements
# if: failure() && ${{ contains(steps.fail.output.commenters, 'github-action') }}
# run: |
# echo "OH NO!"
# env:
# GH_TOKEN: ${{ github.token }}
- name: Get PR number
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
Expand Down

0 comments on commit 82fe32e

Please sign in to comment.