Skip to content

GitHub App to require specific user(s) approval, emitting a Status Check that can be required before merging.

License

Notifications You must be signed in to change notification settings

BrianCArnold/RequireUserApproval

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Require User Approval

CI

A GitHub Action automatically checks to make sure that certain required users have approved a pull request.

Configuration

You need to prepare two YAML files for:

  • Reviewers configuration
  • Workflow configuration

Reviewers configuration

The format of a configuration file is as follows:

groups:
  # The default reviewers
  review-group-all: # This group requires all 4 users to approve a PR.
    members:
      - username1
      - username2
      - username3
      - username4
    required: 4 # the number of members from this group that need to approve a PR.

  review-group-some: # This group requires any 2 users to approve a PR.
    members:
      - username5
      - username6
      - username7
    required: 2

  review-group-any: #This only requires any one user from this group to approve a PR.
    members:
      - username8
      - username9
    required: 1 # the number of members from this group that need to approve a PR.

Important note: Currently, this doesn't check to make sure that the number of required approvals for a group is less than or equal to the number of members specified. Don't set it to require more users than are in the group.

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

Workflow configuration

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

name: Require User Approval

on:
  pull_request_review:
    types: [editted, submitted]

jobs:
  require_user_approval:
    name: Require User Approval
    runs-on: ubuntu-latest
    steps:
      - name: Request review based on files changes and/or groups the author belongs to
        uses: BrianCArnold/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          config: .github/require_reviewers.yml # Config file location override

Thanks to necojackarc's auto-request-review, which this is largely based on.

About

GitHub App to require specific user(s) approval, emitting a Status Check that can be required before merging.

Resources

License

Stars

Watchers

Forks

Packages

No packages published