I would like to use a GitHub action/do some config that automatically requests a review from a team in a GitHub organization (for example core
). I know that you can create pull request templates that automatically request a review from a certain reviewer but how do I do this without creating a template? In summary, I would like to have a team in GitHub core
automatically requested a review for each PR opened. How do I do this?
In general, this is a good use case for the code owners feature: you could have a file .github/CODEOWNERS
that looks like
* @yourorg/core
This requests a review from that team on any pull request opened.
However, this requires the team to have write permissions on the repository, and (as per comments) the intention is to not give this team write permissions.
With the team having only "triage" permissions, this could be achieved with the following workflow:
name: Request review on PRs
on:
pull_request:
types:
- opened
jobs:
request:
name: Request reviews on opened PRs
runs-on: ubuntu-22.04
steps:
- name: Create PR review request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
url: ${{ github.event.pull_request.html_url }}
run: |
gh pr edit "$url" --add-reviewer yourorg/core
This runs on each opened pull request and creates a review request from the yourorg/core
team using the pr edit
command of the GitHub CLI, which is pre-installed on the virtual environments.