I am trying to enable the below in the branch protection.
query
curl -X POST -H "Authorization: Bearer <PAT>" -H "Content-Type: application/json" -d '{
"query": "mutation { createBranchProtectionRule(input: { repositoryId: \"REPO_ID\", pattern: \"release/*\", requiresApprovingReviews: true, requiresCodeOwnerReviews: true, requiredApprovingReviewCount: 1 , requireLastPushApproval: true, requiresConversationResolution: true, dismissesStaleReviews: true , requiresStrictStatusChecks: true , requiresStatusChecks: true ,restrictsPushes : true , requiredDeploymentEnvironments: [\"dev\"]}) { branchProtectionRule { id } } }"
}' https://api.github.com/graphql
output :
{"data":{"createBranchProtectionRule":{"branchProtectionRule":{"id":"BPR_kwDOMI-6g84DL5Qd"}}}}
However it is not getting selected in the protection rule.
Mutation createBranchProtectionRule
needs an input
requiresDeployments: true
in order to enforce deployments.
This mutation creates a BPR with "Require deployments to succeed before merging" checked and environment dev
selected:
mutation {
createBranchProtectionRule(input: {
repositoryId: "REPO_ID",
pattern: "release/*",
requiresDeployments: true,
requiredDeploymentEnvironments: ["dev"]
})
{
branchProtectionRule { id }
}
}