A GitHub Action that labels pull requests with the modules(s) that are impacted in a monorepo.
This GitHub Action runs when an pull_request
event webhook is fired in your GitHub repo. The action checks if any of the files in the pull request are in a module (ex. /directory1/...
from the root of the monorepo). If one or more modules are found, the pull request is labeled with a label for each module repo. Directories that beging with a dot (ex. /.directory/
) are ignored.
Example of PR that has changes in two modules:
Example of monorepo module structure:
To use this GitHub Action, you must have access to GitHub Actions. GitHub Actions are currently only available in private beta (you must apply for access) and only work in private repos.
To setup this action:
- Create a
.github/main.workflow
in your GitHub repo. - Add the following code to the
main.workflow
file and commit it to the repo'smaster
branch.
workflow "Monorepo PR Repo Labeler" {
resolves = ["Label PR Monorepos"]
on = "pull_request"
}
action "Label PR Monorepos" {
uses = "adamzolyak/monorepo-pr-labeler-action@master"
secrets = ["GITHUB_TOKEN"]
}
Optionally add a BASE_DIRS
config under env
if modules are located within a directory. You can add one (ex. directory1
) or more directories (ex. directory1|directory2|...
) in the config.
workflow "Monorepo PR Repo Labeler" {
resolves = ["Label PR Monorepos"]
on = "pull_request"
}
action "Label PR Monorepos" {
uses = "adamzolyak/monorepo-pr-labeler-action@master"
secrets = ["GITHUB_TOKEN"]
env = {
BASE_DIRS = "directory1|directory2"
}
}
- Whenever you open, edit, close, etc a pull request, the action will run!
If you have suggestions for how this GitHub Action could be improved, or want to report a bug, open an issue! Or pull request! We'd love all and any contributions. For more, check out the Contributing Guide.
ISC Β© 2018 Adam Zolyak adam@tinkurlab.com (www.tinkurlab.com)