DEV Community

Hani
Hani

Posted on • Updated on

Check if PR titles follow contribution guidelines

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.


Enter fullscreen mode Exit fullscreen mode

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 to automatically check if pull request titles conform to 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 :P

Usage

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": ""
  }
}
Enter fullscreen mode Exit fullscreen mode

You can pass in one of prefixes or regexp or even both based on your use case. regexpFlags and…

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! πŸ’­

Top comments (2)

Collapse
 
bdougieyo profile image
Brian Douglas • Edited

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

Collapse
 
thehanimo profile image
Hani

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..