Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
at-sign

GitHub Action

Auto Request Review

v0.2.0

Auto Request Review

at-sign

Auto Request Review

Automatically requests review of a pull request based on files changes and/or groups the author belongs to 🤖

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Auto Request Review

uses: necojackarc/[email protected]

Learn more about this action in necojackarc/auto-request-review

Choose a version

Auto Request Review

CI Coverage Status

A GitHub Action automatically requests review of a pull request based on files changes and/or groups the author belongs to 🤖

Notable Features

This GitHub Action enables you to:

  • Auto-assign reviewers based on files changed
  • Auto-assign reviewers based on groups that the author belongs to
  • Auto-assign the default reviwers if no reviwers are matched to your rules
  • Request review only in certain conditions

Auto-assign reviewers based on files changed

You can define reviewers based on files using glob expressions.

files:
  '**/*.js':
    - js-lovers

Auto-assign reviewers based on groups that the author belongs to

If you enable the group assignment feature, you can request code review to all of the other members of the groups you belong to.

reviewers:
  groups:
    js-lovers:
      - js-man
      - js-woman

options:
  enable_group_assignment: false

Auto-assign the default reviwers if no reviwers are matched to your rules

You can define the default reviwers who will be assigned when no reivwers are matched to your rules.

reviewers:
  default:
    - repository-owners

Request review only in certain conditions

If you don't like to have the pull requests considered not yet ready reviewed, you can set ignore_draft and ignored_keywords options.

If your pull request is a draft and ignore_draft is true, review requests won't be made. The same applies if your pull request title contains any of ignored_keywords.

options:
  ignore_draft: true
  ignored_keywords:
    - DO NOT REVIEW

Motivation

It varies depending on the team who should review which pull requests. In some teams, review requests are randomly assigned while others prefer to have them reviewed by every one of the team members. With the default features, code review assignments and code owners, you can cover only a couple of user cases.

This GitHub Action best suits any of the following needs:

  • You'd like to request review based on files changed
  • You'd like to request review to all of the other team members
  • You'd like to keep code owners real code owners, not just reviewers

Overall, if you'd like to request review to a certain set of members based on groups and/or files changed, this GitHub Action works best.

Configuration

You need to prepare two YAML files for:

  • Reviewers configuration
  • Workflow configuration

Reviewers configuration

Create a configuration file where you can define code reviewers in glob expressions. Internally, minimatch is used as a glob implementation.

The format of a configuration file is as follows:

reviewers:
  # The default owners
  defaults:
    - repository-owners
    - octocat

  # Reviewer groups each of which has a list of GitHub usernames
  groups:
    repository-owners:
      - me # username
      - you # username
    core-contributors:
      - good-boy # username
      - good-girl # username
    js-lovers:
      - js-man # username
      - js-woman # username

files:
  # Keys are glob expressions.
  # You can assign groups defined above as well as GitHub usernames.
  '**':
    - repository-owners # group
  '**/*.js':
    - core-contributors # group
    - js-lovers # group
  '**/*.yml':
    - core-contributors # group
    - yamler # username
  '.github/**':
    - octopus # username
    - cat # username

options:
  ignore_draft: true
  ignored_keywords:
    - DO NOT REVIEW
  enable_group_assignment: false

The default configuration file location is .github/auto_request_review.yml but you can override it in your workflow configuration file.

Workflow configuration

Create a workflow file in .github/workflows (e.g. .github/workflows/auto_request_review.yml):

name: Auto Request Review

on:
  pull_request:
    types: [opened, ready_for_review, reopened]

jobs:
  auto-request-review:
    name: Auto Request Review
    runs-on: ubuntu-latest
    steps:
      - name: Request review based on files changes and/or groups the author belongs to
        uses: necojackarc/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          config: .github/reviewers.yml # Config file location override