Created
March 15, 2021 17:10
-
-
Save cvakiitho/a24d37ee7e847148291f4fcaef1ece45 to your computer and use it in GitHub Desktop.
Github Graphql branch protection rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require('node-fetch'); | |
let url = 'https://<>.corp/api/graphql'; | |
let options = { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
Authorization: 'Basic <base64 token>' | |
}, | |
body: '{"query":"mutation createBranchProtectionRule($input:CreateBranchProtectionRuleInput!) {\n createBranchProtectionRule(input:$input){\n branchProtectionRule{\n id\n }\n } \n \n}\n","variables":{"input":{"repositoryId":"<repo_id>","pattern":"major*","dismissesStaleReviews":true,"requiresApprovingReviews":true,"requiredStatusCheckContexts":["continuous-integration/jenkins/pr-merge"],"requiredApprovingReviewCount":1,"isAdminEnforced":true,"requiresStrictStatusChecks":true,"requiresStatusChecks":true}},"operationName":"createBranchProtectionRule"}' | |
}; | |
fetch(url, options) | |
.then(res => res.json()) | |
.then(json => console.log(json)) | |
.catch(err => console.error('error:' + err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment