Skip to content
master
Switch branches/tags
Code
This branch is even with TinkurLab:master.
Contribute

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

🚊 Monorepo PR Repo Labeler - GitHub Action

A GitHub Action that labels pull requests with the modules(s) that are impacted in a monorepo.

How It Works

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. The action also supports configuring a list of one or more base directories if modules are within base directories (ex. /.directory/directory/) such as within Lerna projects, and configuring a label prefix and suffix.

Note: If you're migrating from version 2.x to 3.x, the automatic prefix πŸ“ Repo: <repo> is now optional. If you want to keep this prefix or add a different prefix, see "Adding a custom prefix or suffix to labels" below.

Examples

Example of PR that has changes in two modules: GitHub Logo

Example of monorepo module structure: GitHub Logo

Installation

To setup this action:

  1. Create a .github/worksflows/main.yml in your GitHub repo (more info).
  2. Add the following code to the main.yml file and commit it to the repo's master branch.
name: Monorepo PR Repo Labeler

on: pull_request

jobs:
  labelPR:
    name: Label PR With Repo(s)
    runs-on: ubuntu-latest
    steps:
      - name: Label PRs
        uses: tinkurlab/monorepo-pr-labeler-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BASE_DIRS: 'directory1|directory2' # optional
        with:
          prefix: 'sample_prefix' # optional
          suffix: 'sample_suffix' # optional

Options

  • Add a BASE_DIRS variable under env if modules are located within a base directory(ies). You can configure one (ex. directory1) or more directories (ex. directory1|directory2|...).
  • Add prefix or suffix under with if you wish to add prefix or suffix the repo name in the label respectively.
  1. Whenever you open, edit, close, etc a pull request, the action will run!

Example: Repos in sub directories

The following configuration will look for repos within the folderA and folderB directories:

name: Monorepo PR Repo Labeler

on: pull_request

jobs:
  labelPR:
    name: Label PR With Repo(s)
    runs-on: ubuntu-latest
    steps:
      - name: Label PRs
        uses: tinkurlab/monorepo-pr-labeler-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BASE_DIRS: 'folderA|folderB' # optional

Example: Adding a custom prefix or suffix to labels

The following configuration will prefix each label with πŸ—‚ - ex.πŸ—‚ Repo A, πŸ—‚ Repo B, etc:

name: Monorepo PR Repo Labeler

on: pull_request

jobs:
  labelPR:
    name: Label PR With Repo(s)
    runs-on: ubuntu-latest
    steps:
      - name: Label PRs
        uses: tinkurlab/monorepo-pr-labeler-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          prefix: 'πŸ—‚ ' # optional

Contributing

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.

Maintainers

This repo is mainted by:

  • Adam Zolyak @adamzolyak
  • Anshul Sahni @anshulsahni

License

ISC Β© 2019 Adam Zolyak adam@tinkurlab.com (www.tinkurlab.com)

About

🚊 A GitHub Action that labels PRs with the repo(s) impacted in a monorepo.

Resources

License

Packages

No packages published