A Github Action that automatically assigns reviewers to PR based on changed files
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 }}
- 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
Follow this instruction.
-
Create
repo
scoped PAT. -
Copy the generated PAT to a secret in your repository.
- e.g.
gh secret set PERSONAL_ACCESS_TOKEN -b "ghp_0LAGTTT~~~~AAAA"
- e.g.
-
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 }}
- Add target team to your repository collaborators.
Shuhei Hayashibara |
Shufo2 |
Jonathansadowski |
Andrew Schwenn |
Josh Soref |
Zoltan Haindrich |
Snyk Bot |