🔥Let’s Do DevOps: Creating 60k GitHub Auto-Link References to Jira
This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!
GitHub is a fantastic place for code, but probably isn’t where you’re managing your ticket queue, right? You could use GitHub Issues to keep track of specific issues with a code-base, but your project manager isn’t going to be happy with that — they’d much rather see an aggregate queue of work on all the different team boards in something like Atlassian’s Jira ticketing system.
So all the work comes from Jira, and is implemented in GitHub. Those ticket numbers are all over your code commits, your PR comments, and your git history.
And GitHub has a tremendously useful feature that helps you find your way back to Jira — it’s called an auto-link reference, and it means once configured on a repo, any string in any context (commit message, comment, PR message, etc.) will become a hyperlink and link back to your ticketing system! That could save a heck of a lot of time.
Unfortunately it doesn’t live within an Org configuration — it lives at the Repo level. I have 42 ticket projects to watch for, and I have 1,426 repositories to configure.
That means I need to deploy 59,892 auto-link references. Holy moly.
We’re not going to click our way through that. Let’s write some automation.
Loop Through all the Repos In Your Org
Since all these settings are at the repo level, rather than the Org level, we need to iterate through each repo. I wrote about this in a recent blog, but let’s pull out just the things we need. First, we need to count how many repos we have.
On line 2, we do an authenticated REST call to get all the Organization-level info, including Repo Type counts. We lookup the private counts (line 9) and public cout (line 10), and then add them together on line 11.