REST API v3: wildcard branch protection #24703
-
Is it possible to GET/SET wildcard branch protection using the API? Querying does not seem to work with wildcards at least, although branches being matched are individually shown as being protected, it doesn’t seem possible to tell the difference between ones matching a wildcard, and those with specific settings. |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 1 reply
-
Hi @beiriannydd, Thanks for being here and for asking this question. At this time, this isn’t supported. However, we’re always working to improve, and we consider every suggestion we receive. I’ve logged this in our internal feature request list. Though I can’t guarantee anything or share a timeline for this, I can tell you that it’s been shared with the appropriate teams for consideration. Please let me know if you have any other questions. Cheers! |
Beta Was this translation helpful? Give feedback.
-
Thanks @nadiajoyce . A use case here would be using the terraform github provider. https://github.com/terraform-providers/terraform-provider-github/issues/164 |
Beta Was this translation helpful? Give feedback.
-
Unfortunate that the api support didn’t come in advance of or with the ux support… makes it hard to take advantage of when programatically creating the repositories on behalf of someone who wont have rights to create the restrictions. Hopefully it will be coming in the not too distant future. |
Beta Was this translation helpful? Give feedback.
-
This would be a great feature for organizations which have multiple repos and branches. |
Beta Was this translation helpful? Give feedback.
-
@nadiajoyce - Is there any update on potentially enabling this feature? This is a significant painpoint for migrating my Organization (130+ repos) to GitHub. As is, I’m stuck configuring this manually for each repo as we have a hard requirement for wildcard branch protection. It would be great to be able to automate this. |
Beta Was this translation helpful? Give feedback.
-
+1 for this being a real nuisance and gap in the octokit APIs. It makes no sense that these can be created, edited and deleted manually using the UI, but there is no programmatic mechanism for doing so. Can you please explain the technical details regarding why this is difficult or hasn’t been implemented? |
Beta Was this translation helpful? Give feedback.
-
Hello, I know this question is related to the Rest API v3 and you may have to stick with it but there is a mutation available using the octokit GraphQL API V4. It supports actual pattern such as release/* or hotfix/*. See example below:
You can get the repositoryId using the Rest API or the GraphQL API. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
For anyone trying to work GraphQL into a cURL call / shell script (like I was), after a lot of pain I eventually found success with something like this. You’ll have to rework it for the protections you need, and obviously replace the ‘xxxxxxx’ values with your actual hex IDs. Hopefully this helps someone, I wasn’t able to find examples of this anywhere.
|
Beta Was this translation helpful? Give feedback.
-
Is there any update on this being added to the GitHub Rest API? GitLab solved this issue over 2 years ago and this is a pretty large pain point for our organization in having to update hundreds of repositories manually so they all have the same branch protection rules. For reference we don’t have time/skillset to implement the GraphQL solution and believe this should be supported in the Rest API since it’s possible through the normal web UI. |
Beta Was this translation helpful? Give feedback.
-
Is this request on the radar for GitHub? It would be an extremely helpful feature! |
Beta Was this translation helpful? Give feedback.
-
Any update on this and whether its been added to the roadmap? |
Beta Was this translation helpful? Give feedback.
-
I would be also interested in an update on this API. It feels really strange that the API looks so different from how you configure things in the UI. Likely a historical thing but still, there is no way to reproduce the “clicks” you do on the UI. An example: we have one branch protection for |
Beta Was this translation helpful? Give feedback.
-
Is there any chance of an update from Github on this? We need to make a similar branch protection rule across dozens of repositories that are all based on a wildcard branch name. |
Beta Was this translation helpful? Give feedback.
-
I want to be able to list all branch protection rules on the repo. ThIs currently seems not to be possible with the REST API |
Beta Was this translation helpful? Give feedback.
-
I also have the |
Beta Was this translation helpful? Give feedback.
-
Hey y'all, Probably not the exact answer everyone is looking for but we recently announced the public beta of Repository rules, which is intended to be the future of protected branches. One of the subtle changes for most but relevant for y'all is we have ensured the REST endpoint does support wildcards as well as multiple conditions for matching branches.
|
Beta Was this translation helpful? Give feedback.
Hi @beiriannydd,
Thanks for being here and for asking this question. At this time, this isn’t supported. However, we’re always working to improve, and we consider every suggestion we receive. I’ve logged this in our internal feature request list. Though I can’t guarantee anything or share a timeline for this, I can tell you that it’s been shared with the appropriate teams for consideration.
Please let me know if you have any other questions.
Cheers!