As a LoopBack maintainer, we sometimes add labels to the GitHub issues and pull requests to give others better idea what the issues/PRs are about without looking into the details. While exploring what GitHub Actions can do, I find the Labeler action very useful for this purpose.
Below is what I’ve done to set it up.
- Click the Actions tab, if you haven’t set up any GitHub Actions before, you should see the
Labeler
GitHub Actions towards the bottom of the page.
2. Click the Set up this workflow
button.
3. You’ll see something like below to create a .github/workflows/labeler.yml
file. Commit this file.
Note: By default, the file name is label.yml
. Make sure you have labeler.yml
as the file name.
4. Next, create .github/labeler.yml
to configure what labels to add.
Say I have the following folder structure. What I want to do is to add labeldocs
if the PR changes anything under the docs
folder. Similarly for examples
and repository
labels.
The labeler.yml would look like:
docs: docs/*
example: examples/**/*
repository: packages/repository/*
Then you’re all set! If your PR contains multiple files, the labeler will read all the files and set the labels accordingly.
You can get more information from this Pull Request Labeler page.
Troubleshooting Tips
Issue 1: Got HTTP Error in the labeler check
Make sure you have the following files with the exact file names:
- .github/workflows/labeler.yml
- .github/labeler.yml
Issue 2: Not all the labels were added
It is possible that the .github/labeler.yml
didn’t set properly. For files in the subfolder, make sure you have **/*
.