Skip to content

Automatically add labels by filtering the title and comment of issues and pull requests.

License

Notifications You must be signed in to change notification settings

hoho4190/issue-pr-labeler

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Issue PR Labeler

GitHub Release GitHub License npm Build codecov

About

Automatically add labels by filtering the title and comment of issues and pull requests.


Usage

YAML configuration

Create .github/labeler-config.yml file.

# example
filters:
  - label: feat
    regexs:
      - /\bfeat\b/
      - /feature/i
    events: [issues, pull_request]
    targets: [title, comment]
  - label: bug
    regexs:
      - /fix|bug/
    targets: [title]
  - label: documentation
    regexs:
      - /docs/
    events: [pull_request]
  - label: chore
    regexs:
      - /\bchore(\(.*\))?:/i

Properties

Key Type Value Description
label String label name - Required
- Label name to be added
regexs List<String> regular expression - Required
- List of regular expressions to filter
- Syntax: /pattern/modifier(s)
events List<Event> issues
pull_request
- Optional
- List of events to filter
- Default: [issues, pull_request]
targets List<Target> title
comment
- Optional
- List of target to filter
- Default: [title, comment]

regexs property


Workflow

# example
name: Issue PR Labeler

on:
  issues:
    types:
      - opened
      - edited
  pull_request: # or pull_request_target
    types:
      - opened
      - reopened

jobs:
  main:
    runs-on: ubuntu-latest

    permissions:
      contents: read       # required to read configuration yml file
      issues: write        # required to add labels to issues
      pull-requests: write # required to add labels to pull requests

    steps:
      - name: Run Issue PR Labeler
        uses: hoho4190/issue-pr-labeler@v2.0.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
#          disable-bot: true
#          config-file-name: labeler-config.yml
  • Available events: issues, pull_request, pull_request_target
  • Use the pull_request_target event to allow Labeler to work even when you open a pull request from a forked repository to an upstream repository.

Input

Key Type Description
token String - Required
- Use ${{ secrets.GITHUB_TOKEN }}
disable-bot Boolean - Optional
- Whether to forbid filtering on issues and pull requests created by bots.
- Default: true
config-file-name String - Optional
- Configuration file(yaml) name.
- This file should be located in .github path.
- Default: labeler-config.yml

License

The scripts and documentation in this project are released under the MIT License

About

Automatically add labels by filtering the title and comment of issues and pull requests.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project