A GitHub Action that automatically requests reviews in pull requests from members of a specified team, up to a designated number of reviewers.
name: Automatically request reviews
on:
pull_request:
types: [opened, ready_for_review, reopened]
jobs:
request-reviews:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
steps:
- name: Automatically request reviews
uses: doist/auto-request-reviews-action@v1
with:
reviewers: 2
team: 'Doist/team'
token: ${{ secrets.GITHUB_TOKEN }}
Input | Description | Required |
---|---|---|
reviewers |
Desired total number of reviewers in total | Yes |
team |
Team to pick reviewers from (format: org/team) | Yes |
token |
GitHub token with required permissions (see Permissions) | Yes |
This action:
- Fetches the current pull request and counts how many reviewers are already requested
- Calculates how many more reviewers are needed to reach the specified number
- Gets all members of the specified team, excluding the PR author and existing reviewers
- Randomly selects the required number of reviewers from eligible team members
- If there aren't enough eligible team members, requests as many as possible and logs a warning
The default GITHUB_TOKEN
is not sufficient for this action because it lacks scopes that enable
team member access. You can use a Personal Access Token with the following scopes:
repo
(orpublic_repo
for public repositories)read:org
(required to access team membership)
Store the PAT as a repository secret and pass it in your workflow.
npm install
npm run build
This project uses esbuild for bundling, which creates a single file with all dependencies included.
# Run linter
npm run lint
# Format code
npm run format
This project uses Biome for both linting and formatting.