Github API - Update Branch Protection
I am trying to update the branch protection settings for a repo on github to set Require pull request reviews before merging
to true. I am using the node request
library to make the request.
protectBranch: function(github, org, repo, branch) {
return new Promise((result, reject) => {
let options = {
'url' : github+'/repos/'+org+'/'+repo+'/branches/'+branch+'/protection',
headers: {
'User-Agent': 'nola-guilds-github',
'Authorization': 'token '+process.env.GITHUB_TOKEN,
'Accept': 'application/vnd.github.loki-preview+json'
},
body: {
'required_status_checks' : {
'include_admins' : false,
'strict' : true,
'contexts' : ['default']
},
'required_pull_request_review' : {
'include_admins' : false
},
'restrictions' : null,
'enforce_admins' : false
},
json: true
}
request.put(options, function (error, response, body) {
if(!error && response.statusCode == 200){
result();
} else {
if (error) {
reject(error);
} else {
reject(response);
}
}
});
});
}
I get a 200 response code, and everything else is set correctly, but this one setting. I am at a loss for what the problem could be.
via Jacob Schoen
No comments:
Post a Comment