I'm trying to find some resources on how to add a label automatically when creating a new pull request. So far, I haven't found any documentation on this. Any pointers?
It really depends on what and when you want to label those pull requests. Since there is no rule engine directly on GitHub for this to auto-label issues or pull requests, you have two options:
label. The most used (and Verified) option is Labeler. Here is what a simple setup might look like:# .github/workflows/auto-labeler.yml
name: Auto Label PRs
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Auto Label PR
uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
Then define your logic for how you want labels to be applied. In the case below add the db-migration label anytime a file is created/modified in the db/migrate/* directory
# .github/labeler.yml
db-migration:
- "db/migrate/*"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With