Set all status checks to be required as branch protection using the Github API

I would like to set all status checks that are available to be required for a branch using the Github API.

However, I cannot find a way to retrieve all possible status checks names nor (preferably) just setting all of them to be required.

How can I achieve this?


1 Like

Hi @zethson o/

Been a hot minute since you made this post, so apologies on the delay! We’re trying to go back and find posts that need love and yours was elevated!

The very short answer here? Unfortunately is, you can’t; not via REST or GraphQL. Not easily, in any case.

You can find the protection rules that currently exist on a branch. So if you have an example branch that does contain the rules you want to apply elsewhere, you could leverage:

…to collect the existing rules, then:

You can do similar things with GraphQL but, what you’re asking for, is not the long-path, which is what we have, and really doesn’t solve your use case.

There’s no endpoint to say, pull all rules that have existed for a repository, and then flip them on for a particular branch.

I also want to say it is hypothetically possible to leverage Actions, to perform this task but that’s not something feasible for a response here in this thread.

The path of least resistance lives in the UI and for what you’re after, I’d highly recommend submitting your suggestion, via our feedback form, here:

…and keeping an eye on our public roadmap, here:

Beyond that, if you are feeling ambitious, you may consider what Actions can do, and after taking a shot at it, maybe post under that board with your experience.

Keep well in the meantime, and cheers to you!