Skip to content

shufo/auto-assign-reviewer-by-files

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

CI

Auto Assign Reviewer By Files

A Github Action that automatically assigns reviewers to PR based on changed files

Configuration

create configuration file

.github/assign-by-files.yml

---
# you can use glob pattern
"**/*.js":
  - shufo

".github/workflows/*.yml":
  - shufo2

# you can set multiple reviewers
".github/**/*.yml":
  - foo
  - bar

# you can set team reviewers (repo scope token required)
".github/**/*.md":
  - team: baz

Glob matching is based on the minimatch library.

create action file

.github/workflows/auto-assign.yml

name: "Auto Assign"
on:
  - pull_request

jobs:
  assign_reviewer:
    runs-on: ubuntu-latest
    steps:
      - uses: shufo/[email protected]
        with:
          config: ".github/assign-by-files.yml"
          token: ${{ secrets.GITHUB_TOKEN }}

Example

image

Troubleshooting

Does not match any files

  • Please check if glob pattern is correct or not
# it will matches only js files under the root directory
"*.js":
  - foo
# it will matches `.github/foo.yaml` but not `.github/workflows/bar.yaml`
".github/*":
  - bar
# it will match any files
"**/*":
  - shufo

Use of team reviewers results in: "Could not resolve to a node with the global id of..." error

Follow this instruction.

  1. Create repo scoped PAT.

  2. Copy the generated PAT to a secret in your repository.

    • e.g. gh secret set PERSONAL_ACCESS_TOKEN -b "ghp_0LAGTTT~~~~AAAA"
  3. Use the secret instead of the default GITHUB_TOKEN when running action.

- uses: shufo/[email protected]
  with:
    config: ".github/assign-by-files.yml"
    token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

Use of team reviewers results in: "Reviews may only be requested from collaborators..."

Contributors

shufo
Shuhei Hayashibara
shufo2
Shufo2
jonathansadowski
Jonathansadowski
aschwenn
Andrew Schwenn
jsoref
Josh Soref
kgyrtkirk
Zoltan Haindrich
snyk-bot
Snyk Bot

About

A Github Action automatically assigns reviewers to PR based on changed files

Resources

License

Stars

Watchers

Forks

Packages

No packages published