Use this Github action to automatically add a label to PRs based on the teams the PR author belongs to.
At EquityBee, we use a large monorepo where multiple teams/squads collaborate. Due to Github's PR filtering limitations, we built this action to easily filter PRs based on the author's team membership.
For the action to work, the author must be a member of a team on Github.
Under .github/workflows
create a new .yml
file to run the action on every PR:
name: Assign PR team labels
on:
pull_request:
branches:
- main
jobs:
team-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: equitybee/team-label-action@main
with:
repo-token: ${{ secrets.TOKEN }}
organization-name: YOUR_ORGANIZATION_NAME
Make sure to add the relevant inputs:
repo-token
is your${{ secrets.GITHUB_TOKEN }}
. You may encounter an error where this token does not have the necessary permissions to access an organization or teams. At EquityBee, we use PATs (Personal Access Token) instead. Create a personal access token with the repo or public_repo scopes enabled, and add the token as an encrypted secret for the repository or organizationorganization-name
is the name/slug of your Github organization (it comes right afterhttps://github.com/
)ignore-labels
is an optional, comma-separated list of labels to ignoreprefix
is an optional prefix that will be added to all team labels
You may wonder why Husky is running a pre-commit script: we are copying its contents directly in our monorepo. Husky makes sure the dist/
directory always contains the latest, built action.
- add tests
Apache-2 © EquityBee