DEV Community 👩‍💻👨‍💻

Cover image for pr-compliance-action
Matthew Foley
Matthew Foley

Posted on

pr-compliance-action

I started contributing to the Open Sauced project earlier this year, and I have really enjoyed it. @bdougieyo has put together a great community around this project, and I've learned quite a bit about Jamstack, Git, React, and the Github platform as I've put together PRs for this project.

This was before my time, but apparently during last year's Hacktoberfest, the Open Sauced maintainers (along with other maintainers on Github) got a lot more pull requests than they were ready for, and the quality was not always what they hoped to see. One thing that was especially important was that every PR would ideally be related to an issue that had already been created. I had my challenges as I got started in contributing, so I can see where the learning curve is in submitting PRs that comply with a project's Contributing Guidelines. On the other hand, I can see what kind of time commitment can be involved in making sure that inbound PRs aren't put together in a way that will have a negative impact on the project.

In watching live streams and in other venues, I had heard @bdougieyo talk a handful of times about having a GitHub Action that would look at multiple aspects of an incoming PR other than the code modifications, and take appropriate steps such as leaving a comment with what needed to be adjusted, and possibly closing the PR. I had been wanting to make a GitHub action of my own, and the business logic seemed like it would be straightforward enough.

Inspired by this need of the project, and some of the work in pr-lint-action, I managed to create and do a pre-release on pr-compliance-action, and it was implemented in the Open Sauced project last week!

pr-compliance-action Functionality

It looks for the following:

  • PR Title formatted according to @commitlint/conventional-commit.
  • PR Body refers to an issue, as detected by a regular expression
  • PR originates from a protected branch e.g. "main", (based on head ref)
  • PR includes modifications to specific files that should be reviewed carefully (e.g. package.json)

This action drives the following outcomes by default, but these can be tweaked:

Check Outcome on Failure
PR Title Lint Fails Action shows as failed check. Action leaves comment.
PR without linked Issue Action closes issue. Action leaves comment.
PR Originates from Protected Branch Action closes issue. Action leaves comment.
PR Updates Watched Files Action leaves comment.

Try It Out

I hope that someone can find value in this Github Action - I'd love to hear what folks think of it!

Top comments (2)

Collapse
0vortex profile image
TED Vortex (Teodor Eugen Duțulescu)

Would love this to mirror some of the default GitHub flows and some closed source ones via "templates" or "presets", making this awesome action potentially zero to 1 line configurable for everybody. Looking to use this everywhere, essentially, and blown away by the level of customisation you put into it in such a short time frame!

Collapse
blackgirlbytes profile image
Rizèl Scarlett

I learned something new! bravo 👏

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.