🔥Let’s Do DevOps: GitHub Power User — Find All PRs with Specific Title Org-Wide with Rest API

Kyler Middleton
5 min readDec 4, 2022

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!

Recently, I’ve been getting our GitHub Enterprise up to snuff. For other CI platforms, you’d set policies at the Enterprise level that all the Orgs and Repos would inherit — e.g., permissions. There’s also usually robust search for things.

However, those features are either not quite present or are presented as a “you can do it… with the API”. So let’s do it. With the API!

Let’s dive into why you might need to search your whole Org for every Repo, and look at each PR. If you’d rather skip to code, scroll to the bottom of this article and click on the GitHub link — all code provided so you can build it too!

The Problem

In some CI tools, you have the ability to set a single Action/Automation as a required run, and set a single pipeline that must run for every PR to qualify to be merged. There are lots of justifications for this — a tool that does static analysis of code, a code linter, a tool which validates that organization best-practices were followed.

GitHub lets you do this only at the single-Repo level. Which sounds totally reasonable until you need to deploy a tool like I described above to hundreds of repos. That’s a huge, annoying problem. And I have a write-up coming for the tool I’ve built to do just that — iterate through all repos, add Action(s), commit them, push to remote, and open a PR.

However, imagine we’re past that. You’ve now opened 180 PRs and need to track how many remain open so you can poke the teams that control those repos and haven’t yet taken care of merging them yet. Manually searching for those PRs is an annoying problem.

One which can be solved with GitHub’s robust REST API and a bit of scripting magic. The script I wrote is linked at the bottom of this write-up. Let’s step through each section and what it does. That’s not much to it at all.

Input Mapping

Kyler Middleton

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