🔥Let’s Do DevOps: GitHub Action — Check if Each Commit Contains Valid Jira Ticket ID

Kyler Middleton
8 min readFeb 27

This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!

Hey all!

I’ve been running a project in my enterprise to migrate all our code from an internal BitBucket server to GitHub. This BitBucket server is older, and uses a great deal of modules from the community to support all sorts of cool bespoke features. I’ve been doing my best to replicate those features in GitHub using a mixture of ingenuity and Actions.

One of those features is called the Yet Another Commit Checker. It integrated with BitBucket to validate any commit pushed to the server contains a reference to a valid Jira ticket, and works well.

The YACC (an amazing short name for this module) did all this validation pre-commit push to the server. So if a commit wasn’t valid, the git push was rejected and a message (with an adorable teddy bear) was printed to the terminal.

GitHub Cloud (different from GitHub server, which lives within your org) doesn’t support pre-commit checks. They fear they’d be DoS’d by folks sending them hundreds of thousands of commits, and the asymetric validation required on their side would down their services.

So we’re stuck with validating post-push. That’s okay, folks will need to rebase their PRs, rather than amending their commits locally. No big deal.

Let’s talk about how the Action works and I’ll share what we built. Scroll to the end of this article for a link to the Action itself if you want to borrow it for your own Org.

NOTE: This is an actual GitHub Action in the Marketplace, my first one! I hope it’s useful to you :) ❤

Temp Measure: Regex!

As a temporary measure, I created an Action that can live in each repo and validate post-commit-push that each commit matches a regex for how our tickets look. Link:

Kyler Middleton

DevNetSecOps, DevRel, cloud security chick. I will teach you, it’s unavoidable. She/Her 🏳️‍🌈🏳️‍🌈, INFJ-A, support the EFF!

Recommended from Medium

Lists

See more recommendations