Github API can't update required status checks of protected branch #24424
-
I am an owner of my org repositories and I have more than a thousand of it, so I write automation scripts with API calls to manage GitHub repository settings. The following is an example of the issue: I have a github repository which has branch protection settings for relase branch: { I ran the following command to update required status checks of protected branch: curl -sS -X PATCH “$GITHUB_API/repos/mdsol/go-cd-test/branches/release/protection/required_status_checks” -H “Authorization: token $TRAVIS_TOKEN” -H “Accept: application/vnd.github.luke-cage-preview+json” -d ‘{“strict”:false,“contexts”:[“GoCD”]}’ but it returned: } I searched the documents and can’t find anything helpful to enable “Required status checks” through API calls. Do you have any ideas and suggestions? Thanks! I don’t want to use “-X PUT” because I want to keep existing branch protection rules and they are very diverse in repositories. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @tonyzwei, This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our community organized so users can more easily find information. As you’ll notice, your topic is now here in the GitHub API board. No action is needed on your part; you can continue the conversation as normal here. Cheers! |
Beta Was this translation helpful? Give feedback.
-
Hi Tony, As you found out, you will need to enable the required status checks via the Update Branch Protection API Endpoint first. You will have to extract the current configuration first with the Get Branch Protection API Endpoint. François |
Beta Was this translation helpful? Give feedback.
Hi Tony,
As you found out, you will need to enable the required status checks via the Update Branch Protection API Endpoint first.
You will have to extract the current configuration first with the Get Branch Protection API Endpoint.
François