Listing the status of your branch protection in GitHub
I've recently been doing an audit of my branches across the repos I have on GitHub, and needed a way to list all the protection in place across various repos.
To make it easier, I've created a Go tool, which can be installed like:
go install gitlab.com/tanna.dev/github-branch-protection@HEAD
Then, create a file i.e. repos.txt
i.e.:
jamietanna/jamietanna
jamietanna/pages-testing
Then run:
github-branch-protection repos.txt
And it'll output a Tab Separated Value (TSV) formatted output, such as:
Organisation | Repo | Branch | Branch exists? | Branch protected? | Any required status checks? | Required status checks | Strict status checks? | Push restrictions? | Admins included? | Force pushes allowed? | Deletions allowed? | PR review required? | CODEOWNERS required to review? | Review bypasses allowed for? |
jamietanna | jamietanna | main | true | false | ||||||||||
jamietanna | jamietanna | master | false | |||||||||||
jamietanna | pages-testing | main | true | true | false | false | true | false | false | true | true | |||
jamietanna | pages-testing | master | false |