Improve the PR workflow actions

This patch includes two changes to the PR handling workflow:

(1) It changes the trigger for the workflow to pull_request_target. So,
    PRs can now also be assigned to reviewers if the PR is opened from
    external sources.

(2) A workflow has been added that automatically assigns PRs to the
    author.
This commit is contained in:
Jan Nidzwetzki 2022-12-01 09:57:09 +01:00 committed by Jan Nidzwetzki
parent 2c70dc622e
commit 1751efbaea
4 changed files with 42 additions and 30 deletions

38
.github/workflows/pr-handling.yaml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Assign PR to author and reviewers
# This workflow runs on the pull_request_target event:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
#
# So the secrets are accessible even if the PR was opened from an external
# repository. This is done because the GitHub API key needs to be accessed
# to modify the PRs.
#
# NOTE: Only API calls should be made in the actions defined here. The
# committed code should _NOT_ be touched in any case.
on:
pull_request_target:
types: [ opened, reopened ]
jobs:
assign-pr:
name: Assign PR to author
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.6.1
ask-review:
name: Run pull-review
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run pull-review with docker
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
PULL_REQUEST_NUMBER : ${{ github.event.pull_request.number }}
shell: bash
run: |
PR_URL="https://github.com/${OWNER}/${REPO}/pull/${PULL_REQUEST_NUMBER}"
docker run ghcr.io/imsky/pull-review "$PR_URL" --github-token "${GITHUB_TOKEN}"

View File

@ -1,19 +0,0 @@
name: Run pull-review with docker
on:
pull_request:
jobs:
ask-review:
name: Run pull-review
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run shell script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
PULL_REQUEST_NUMBER : ${{ github.event.pull_request.number }}
shell: bash
run: |
PR_URL="https://github.com/${OWNER}/${REPO}/pull/${PULL_REQUEST_NUMBER}"
bash scripts/pull-review.sh "${GITHUB_TOKEN}" "${PR_URL}"

View File

@ -39,7 +39,6 @@ require_notification: false
reviewers: reviewers:
svenklemm: {} svenklemm: {}
mkindahl: {} mkindahl: {}
mfundul: {}
fabriziomello: {} fabriziomello: {}
konskov: {} konskov: {}
erimatnor: {} erimatnor: {}
@ -49,6 +48,10 @@ reviewers:
RafiaSabih: {} RafiaSabih: {}
gayyappan: {} gayyappan: {}
jnidzwetzki: {} jnidzwetzki: {}
mahipv: {}
lkshminarayanan: {}
sb230132: {}
shhnwz: {}
# list of users who will never be notified # list of users who will never be notified
review_blacklist: review_blacklist:

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
#
# This script runs pull-review on a pull request
# to intelligently assign reviewers to it.
#
PULL_REVIEW_GITHUB_TOKEN=$1
PULL_REQUEST_URL=$2
docker run ghcr.io/imsky/pull-review $PULL_REQUEST_URL --github-token $PULL_REVIEW_GITHUB_TOKEN