This GitHub Action automatically assigns a specified number of random reviewers to a pull request. It fetches events for the repository to identify active users and adds them as reviewers to the PR.
on:
pull_request_target:
types: [opened, ready_for_review, reopened]
jobs:
example_assign_reviews:
runs-on: ubuntu-latest
name: An example job to assign reviewers
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Assign random reviewers to PR
uses: ihs7/action-reviewer-roulette@v1
with:
number-of-reviewers: 2If you are using peter-evans/create-pull-request to create pull requests, you can use this action to subsequently add random reviewers to the pull request created.
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
- name: Assign random reviewers to PR
uses: ihs7/action-reviewer-roulette@v1
if: ${{ steps.cpr.outputs.pull-request-number }}
with:
number-of-reviewers: 2
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}All inputs are optional. If not set, sensible defaults will be used.
| Name | Description | Default |
|---|---|---|
token |
GITHUB_TOKEN (permissions contents: write and pull-requests: write) or a repo scoped Personal Access Token (PAT). |
GITHUB_TOKEN |
pull-request-number |
The number of the pull request to assign reviewers. | ${{ github.event.pull_request.number }} |
number-of-reviewers |
The number of reviewers add to the PR | 1 |
max-number-of-reviewers |
The maximum number of reviewers for the PR, only adds reviewers up to this number | '' |
excluded-reviewers |
Comma separated list of GitHub usernames to exclude from the random selection | '' |
dry-run |
Useful when testing the action, does everything but add reviewers to PR | false |
You can exclude users from the random selection by providing a comma-separated
list of GitHub usernames in the excluded-reviewers input.
- name: Assign random reviewers to PR
uses: ihs7/action-reviewer-roulette@v1
with:
number-of-reviewers: 2
excluded-reviewers: 'happyhut,virtualhorse,howpufferfish'The default GITHUB_TOKEN should have permission needed to run this action.
If you are using granular permissions in your GitHub Actions workflow file and
seeing Resource not accessible by integration error, the action needs the
following permissions:
permissions:
contents: read
pull-requests: writeSee jobs.<job_id>.permissions for more information.
Run tests with Node's test runner:
node --test