loading...

Check if PR titles follow contribution guidelines

thehanimo profile image Hani ・Updated on ・1 min read

My Workflow

Contribution guidelines of popular projects often include a recommended title styling like this one from facebook/docusaurus:

feat: allow overriding of webpack config
^--^  ^------------^
|     |
|     +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.

PR Title Checker helps maintainers organise their projects better by tagging titles that do not conform to such guidelines. No, it doesn't check if the summary is in present tense πŸ˜…. At least not yet!

Pull Request Titles can be checked for certain prefixes (or even regexps, or both!) and tagged automatically if they fail to comply. This usually prompts the author themselves to fix it so that when a maintainer wakes up from their hard-fought night's sleep, they don't have to be faced with weirdly named pull requests even after they had it all perfectly laid out in the Contribution guidelines. Oh and btw, this little Github action can also show you if the author has reaaaaally read the Contribution Guidelines ;)

Submission Category:

Maintainer Must-Haves (or Wacky Wildcards for Maintainers perhaps? πŸ€”)

Yaml File or Link to Code

GitHub logo thehanimo / pr-title-checker

An action for automatically checking if pull request titles conform to the Contribution Guidelines

Pull Request 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 πŸ˜‰

Usage

Create a .github/pr-title-styles.json like this one below:

{
  "LABEL": {
    "name": "title needs formatting"
    "color": "EEEEEE"
  }
  "CHECKS": {
    "prefixes": ["fix: ", "feat: "]
    "regexp": "docs\\(v[0-9]\\): "
  }
}

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.

Create Workflow

Create a workflow (eg: .github/workflows/pr-title-cheker.yml see Creating a Workflow file) to utilize the pr-title-checker action with content:

name: "PR Title
…

Additional Resources / Info

This was my first shot at building a Github action (and a DEV post!). Since it's just released, not many projects use it yet! (You can help change that here πŸ™‚)

Would love to hear your thoughts below! πŸ’­

Discussion

pic
Editor guide
Collapse
bdougieyo profile image
Brian Douglas

Hey, great action Hani. Curious how you validate if the contribution ha read the guidelines?

Collapse
thehanimo profile image
Hani Author

Thanks a lot Brian! Well, if they did read the guidelines, the title would match the required template and the action wouldn't tag it as "title needs formatting". So if you see a PR being tagged by this action despite having clear title formatting requirements, it is possible that the author missed that part πŸ˜… It is kinda quirky in a way..