Skip to content

GitHub Action that automatically requests pull request reviews

License

Notifications You must be signed in to change notification settings

Doist/auto-request-reviews-action

Repository files navigation

Auto Request Reviews Action

A GitHub Action that automatically requests reviews in pull requests from members of a specified team, up to a designated number of reviewers.

Usage

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 }}

Inputs

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

How it works

This action:

  1. Fetches the current pull request and counts how many reviewers are already requested
  2. Calculates how many more reviewers are needed to reach the specified number
  3. Gets all members of the specified team, excluding the PR author and existing reviewers
  4. Randomly selects the required number of reviewers from eligible team members
  5. If there aren't enough eligible team members, requests as many as possible and logs a warning

Permissions

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 (or public_repo for public repositories)
  • read:org (required to access team membership)

Store the PAT as a repository secret and pass it in your workflow.

Development

Setup

npm install

Build

npm run build

This project uses esbuild for bundling, which creates a single file with all dependencies included.

Lint & Format

# Run linter
npm run lint

# Format code
npm run format

This project uses Biome for both linting and formatting.

About

GitHub Action that automatically requests pull request reviews

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published