1
0
mirror of https://github.com/arduino/library-registry.git synced 2025-07-29 14:01:15 +03:00

Add a dedicated "Manage PRs" workflow job for review request

The workflow result might indicate either that the PR author could require assistance from a maintainer or that something
is wrong with the system. In this case, the situation is brought to the attention of the maintainers by requesting a pull
request review from them.

Due to the need to avoid requesting review from a maintainer when they are the PR author (which is not allowed and thus
would result in a spurious workflow failure), the code for requesting this review is not as trivial as might be expected.
Previously, this code was duplicated at multiple places in the workflow, and would become more so as additional code is
added. The workflow is made cleaner by moving that duplicated code to a single dedicated job, which is facilitated by the
recent reworking of the workflow structure.

This is a pure refactoring and should have no effect on the workflow behavior.
This commit is contained in:
per1234
2021-07-24 04:39:23 -07:00
parent ec4a8a8be1
commit c674fc0225

View File

@ -470,37 +470,12 @@ jobs:
Once that is done, it will be merged automatically.
- name: Request a review in case assistance is required
if: contains(toJSON(env.MAINTAINERS), github.actor) != true # Don't attempt to request review from PR author.
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
reviewers: ${{ env.MAINTAINERS }}
not-submission:
needs:
- parse
if: needs.parse.outputs.type != 'submission' # These request types can't be automatically approved.
runs-on: ubuntu-latest
steps:
- name: Request pull request review
if: contains(toJSON(env.MAINTAINERS), github.actor) != true
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
reviewers: ${{ env.MAINTAINERS }}
- name: Comment on required review
uses: octokit/request-action@v2.x
env:
@ -543,18 +518,6 @@ jobs:
labels: |
- "status: maintenance required"
- name: Request pull request review
if: contains(toJSON(env.MAINTAINERS), github.actor) != true
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
reviewers: ${{ env.MAINTAINERS }}
- name: Comment on unexpected failure
uses: octokit/request-action@v2.x
env:
@ -582,3 +545,29 @@ jobs:
:warning::warning::warning::warning:
SLACK_COLOR: danger
MSG_MINIMAL: true
request-review:
needs:
- merge-fail
- not-submission
- unexpected-fail
if: >
always() &&
(
needs.merge-fail.result != 'skipped' ||
needs.not-submission.result != 'skipped' ||
needs.unexpected-fail.result != 'skipped'
)
runs-on: ubuntu-latest
steps:
- name: Request pull request review from maintainer
if: contains(toJSON(env.MAINTAINERS), github.actor) != true # Don't attempt to request review from PR author.
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
reviewers: ${{ env.MAINTAINERS }}