gh api repos/:owner/:repo/branches/main/protection
See https://docs.github.com/en/rest/reference/repos#update-branch-protection
echo '{
"required_status_checks": {
"strict": true,
"contexts": ["contexts"]
},
"enforce_admins": true,
"required_pull_request_reviews": {
"dismissal_restrictions": {
"users": ["users"],
"teams": ["teams"]
},
"dismiss_stale_reviews": false,
"require_code_owner_reviews": false,
"required_approving_review_count": 1
},
"restrictions": {
"users": ["users"],
"teams": ["teams"],
"apps": ["apps"]
}
}' >/tmp/config-branch-rules
gh api --method PUT repos/:owner/:repo/branches/main/protection --input /tmp/config-branch-rules >/dev/null