GitHub Action
PR Title Checker
This action checks if PR titles conform to the Contribution Guidelines ☑️
Consistent title names help maintainers organise their projects better 📚
Shows if the author has reaaaaally read the Contribution Guidelines :P
Create a config file .github/pr-title-checker-config.json
like this one below:
{
"LABEL": {
"name": "title needs formatting",
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["fix: ", "feat: "],
"regexp": "docs\\(v[0-9]\\): ",
"regexpFlags": "i",
"ignoreLabels" : ["dont-check-PRs-with-this-label", "meta"]
},
"MESSAGES": {
"success": "All OK",
"failure": "Failing CI test",
"notice": ""
}
}
You can pass in one of prefixes
or regexp
or even both based on your use case. regexpFlags
and ignoreLables
are optional fields.
If none of the checks pass, a label will be added to that pull request.
If at least one of them passes, the label will be removed.
This action causes CI tests to fail by default. However, if you don't want CI tests failing just because of this action, simply set alwaysPassCI
as true in the CHECKS field.
Also, adding label names to the optional ignoreLabels
field will forfeit any checks for PRs with those labels.
Create a workflow (eg: .github/workflows/pr-title-checker.yml
see Creating a Workflow file) to utilize the pr-title-checker action with content:
name: "PR Title Checker"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- labeled
- unlabeled
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: thehanimo/pr-title-checker@v1.3.4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
configuration_path: ".github/pr-title-checker-config.json"
NOTE:
-
pull_request_target
event trigger should be used (notpull_request
) in order to support checking PRs from forks. This was added inv1.3.2
. See #8. -
pass_on_octokit_error
is an optional input which defaults to false. Setting it to true will prevent the CI from failing when an octokit error occurs. This is useful when the environment this action is run in is not consistent. For e.g, it could be a missing GITHUB_TOKEN. Thanks to @bennycode for pointing this out. -
configuration_path
is also an optional input which defaults to".github/pr-title-checker-config.json"
. If you wish to store your config file elsewhere, pass in the path here.