A GitHub Action that automates labeling on issues and pull requests.
auto-labeling
automatically detects task lists in the description of an issue or a pull request and adds labels based on their states (checked or unchecked).
<!-- pull_request_template.md -->
What kind of change does this PR introduce?
- [x] `bug-fix`
- [ ] `new-feature`
- [ ] `enhancement`
This description makes auto-labeling
add bug-fix
. If someone updates the description as follows:
<!-- pull_request_template.md -->
What kind of change does this PR introduce?
- [ ] `bug-fix`
- [ ] `new-feature`
- [x] `enhancement`
Then, auto-labeling
removes bug-fix
and adds enhancement
. Note that unregistered labels are ignored.
name: Auto Labeling
on:
issues:
types:
# Trigger the action only on relevant activity types.
# It's actually not harmful to trigger the action on all activity types.
- opened
- edited
on:
pull_request:
types:
- opened
- edited
# A GitHub token created for a PR coming from a fork doesn't have
# 'admin' or 'write' permission (which is required to add labels)
# To avoid this issue, you can use the `scheduled` event and run
# this action on a certain interval.
on:
schedule:
- cron: '*/10 * * * *'
jobs:
labeling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: harupy/auto-labeling@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
label-pattern: '- \[(.*?)\] ?`(.+?)`' # matches '- [x] `label`'
inputs:
github-token:
description: 'GitHub token'
required: true
label-pattern:
description: >
Pattern (regular expression) to extract label states and names (e.g. '- \[(.*?)\] ?`(.+?)`').
required: true
offset:
description: >
Only issues and pull requests updated at or after this offset (from the current time) will be labeled.
Required only when running this action on the schedule event.
required: false
default: '1m' # means one month
quiet:
description: >
Suppress logging output. Must be either "true" or "false"
required: false
default: 'false'