Automatically label and comments to new issues or pull requests based on the contents.
Create a .github/issue-checker.yml
file with a list of labels and regex to match to apply the label.
# For labels
labels:
- name: label-1
# Add `bug` label if issue contains the word `Bug` or `bug`; Remove if not
content: bug
regexes: '[Bb]ug'
- name: enhancement
# Add `enhancement` label if issue match all of the regexes; Remove if not; Skip if the label `bug` have been added;
regexes: '[Ee]nhancement|[Ff]eature [Rr]equest'
skip-if:
- label-1
- name: label-3
# Add `Collaborator` label if the issue author is a COLLABORATOR.
content: Collaborator
author_association: COLLABORATOR
# For comments
comments:
- name: comments-1
# Comment the content below if issue contains the word `Uploading`
content:
"You have some files that did not upload successfully, please re-upload them."
regexes:
'Uploading'
- name: comments-2
# Comment the content below if issue contains the links that include snippets listed in url_list
content:
There are unconfirmed links, please visit with caution.
url_mode: deny
url_list:
- example\.com/asd # regex
- name: comments-3
# Comment the content below if issue contains the links that don't include any snippets listed in url_list
content:
There are unconfirmed links, please visit with caution.
url_mode: allow_only
url_list: # You can use any string property of URL: "hash" | "host" | "hostname" | "href" | "origin" | "password" | "pathname" | "port" | "protocol" | "search" | "username"
- hostname: (?:^|.+\.)github\.com$
pathname: ^/exapmle-user/example-repo
The format of the configuration file is shown below.
default-mode: # optional
pull_request: # optional, choices [pull_request, pull_request_target, issues, issue_comment]
- add # optional, choices [add, remove]
- ...
...
labels: # optional, choices [labels, comments]
- name: string # required
content: string # optional, default ${name}
regexes: # optional, required if ${author_association} undefined
string[] | string
url_mode: # optional, ignored if ${regexes} exists
"allow_only" | "deny"
url_list: # optional, ignored if ${regexes} exists, keeps in mind that if `search` has valud that is must be started with `?` which needs to be escaped
(string | Partial<Pick<URL, { [K in keyof URL]: URL[K] extends string ? K : never; }[keyof URL]>>)[]
author_association: # optional, required if ${regexes} undefined
string
remove-if: # optional
string[] | string
skip-if: # optional
string[] | string
mode: # optional
pull_request: # optional, choices [pull_request, pull_request_target, issues, issue_comment]
- add # optional, choices [add, remove]
- ...
...
- ...
...
Create a workflow (eg: .github/workflows/issue-checker.yml
see Creating a Workflow file) to utilize the labeler action with content:
name: "Issue Checker"
on:
issues:
types: [opened, edited]
pull_request_target:
types: [opened, edited]
jobs:
triage:
permissions:
contents: read
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: MaaAssistantArknights/issue-checker@v1.14
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/issue-checker.yml
not-before: 2022-08-01T00:00:00Z
include-title: 0
sync-labels: 1
Warning: Do not use triggers other than pull_request
, pull_request_target
, issues
and issue_comment
, unless you know what you are doing.
Note: This grants access to the GITHUB_TOKEN
so the action can make calls to GitHub's rest API.
Various inputs are defined in action.yml
to let you configure the issue-checker:
Name | Description | Default |
---|---|---|
repo-token |
Token to use to authorize label changes. | N/A |
configuration-path |
The path to the label configuration file | N/A |
sync-labels |
Whether or not to remove labels when not match | 1 |
include-title |
Whether or not the title participate in matching | 0 |
not-before |
Any issues prior to this timestamp will be ignored (blank to handle all issues) | N/A |