Git Product home page Git Product logo

monorepo-pr-labeler-action's Introduction

๐ŸšŠ 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. /module1/..., /module2/..., 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.

Details

  • Directories that beginning with a dot (ex. /.directory/) are ignored.
  • The action supports configuring a list of one or more base directories if modules are within base directories (ex. /base_directory1/module1/, /base_directory1/module2/, /base_directory2/module3/) such as within Lerna projects
  • The action supports configuring label prefix and label suffix for labeling.

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
          separator: ' ' # optional

Options

  • Optionally add a BASE_DIRS variable under env if modules are located within one or more base directory(ies). You can configure one (ex. base_directory1) or more directories (ex. base_directory1|bae_directory2|...). If BASE_DIRS isn't specified, the action will assume the base directories in the repo are your modules (ex. base_directory1 is a module).
  • Add prefix or suffix under with if you wish to add prefix or suffix the repo name in the label respectively.
  • Add separator under with if you wish to add a separator between the prefix, label, and suffix. For example, using a single space character ' ' will add a space between them. By default, no separator is added.

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@master
        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 ๐Ÿ—‚ and add a space after the prefix - 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@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          prefix: '๐Ÿ—‚' # optional
          separator: ' ' # 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 maintained by:

  • Adam Zolyak @adamzolyak
  • Anshul Sahni @anshulsahni

License

ISC ยฉ 2021 Adam Zolyak [email protected] (www.tinkurlab.com)

monorepo-pr-labeler-action's People

Contributors

adamzolyak avatar anshulsahni avatar dependabot[bot] avatar jarrku avatar anandchowdhary avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.