mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 13:07:56 +00:00
d212fc7a41
This PR includes two changes: - added `workflow_dispatch` to review bot - reverted #4271 ### Added `workflow_dispatch` to review bot This allows us, in the case that review-bot fails for some fork reasons, to trigger it manually ensuring that we can overcame the problem with the multiple actions while we look for a solution. <img width="342" alt="image" src="https://github.com/paritytech/polkadot-sdk/assets/8524599/f432f91b-829a-4da4-b4ca-54cc4fe280c8"> ### Reverted #4271 Unfortunately, the changes added in #4271 do not work in forks. Here is a lengthy discussion of many individuals facing the same problem as me: - [GitHub Action `pull_request` attribute empty in `workflow_run` event object for PR from forked repo #25220](https://github.com/orgs/community/discussions/25220) So I had to revert it (but I updated the dependencies to latest). #### Miscellaneous changes I added a debug log at the end of review bot in case it fails so we can easily debug it without having to make a lot of boilerplate and forks to duplicate the environment.
74 lines
3.3 KiB
YAML
74 lines
3.3 KiB
YAML
name: Review-Trigger
|
|
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
- review_requested
|
|
- review_request_removed
|
|
- ready_for_review
|
|
pull_request_review:
|
|
|
|
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')) }}
|
|
runs-on: ubuntu-latest
|
|
name: trigger review bot
|
|
steps:
|
|
- name: Skip merge queue
|
|
if: ${{ contains(github.ref, 'gh-readonly-queue') }}
|
|
run: exit 0
|
|
- name: Get PR data
|
|
id: comments
|
|
run: |
|
|
echo "bodies=$(gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json comments --jq '[.comments[].body]')" >> "$GITHUB_OUTPUT"
|
|
echo "reviews=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews --jq '[.[].state]')" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
- name: Fail when author pushes new code
|
|
# Require new reviews when the author is pushing and he is not a member
|
|
if: |
|
|
contains(fromJson(steps.comments.outputs.reviews), 'APPROVED') &&
|
|
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 != 'CONTRIBUTOR' &&
|
|
github.event.pull_request.author_association != 'MEMBER'
|
|
run: |
|
|
echo "User's association is ${{ github.event.pull_request.author_association }}"
|
|
# We get the list of reviewers who approved the PR
|
|
REVIEWERS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.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.pull_request.number }}/requested_reviewers --input -
|
|
|
|
echo "::error::Project needs to be reviewed again"
|
|
exit 1
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
- name: Comment requirements
|
|
# If the previous step failed and github-actions hasn't commented yet we comment instructions
|
|
if: failure() && !contains(fromJson(steps.comments.outputs.bodies), 'Review required! Latest push from author must always be reviewed')
|
|
run: |
|
|
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "Review required! Latest push from author must always be reviewed"
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
COMMENTS: ${{ steps.comments.outputs.users }}
|
|
- name: Get PR number
|
|
env:
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
echo "Saving PR number: $PR_NUMBER"
|
|
mkdir -p ./pr
|
|
echo $PR_NUMBER > ./pr/pr_number
|
|
- uses: actions/upload-artifact@v4
|
|
name: Save PR number
|
|
with:
|
|
name: pr_number
|
|
path: pr/
|
|
retention-days: 5
|