š„Letās Do DevOps: GitHub Action ā Check if Each Commit Contains Valid Jira Ticket ID
--
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: