forked from NHSDigital/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added default branch protection script.
- Loading branch information
1 parent
fbd3c7e
commit fd46409
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Github | ||
|
||
## Branch Protection Rules | ||
|
||
This will create the default branch protection rules using github API. | ||
|
||
``` | ||
./branch-protection.sh $reponame $PAT | ||
``` | ||
|
||
PAT must have `administration:write`. https://docs.github.com/en/rest/repos/rules?apiVersion=2022-11-28#create-a-repository-ruleset |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
curl --location "https://api.github.com/repos/NHSDigital/$1/rulesets" \ | ||
--header 'X-GitHub-Api-Version: 2022-11-28' \ | ||
--header 'Accept: application/vnd.github+json' \ | ||
--header "Authorization: Bearer $2" \ | ||
--header 'Content-Type: application/json' \ | ||
--data '{ | ||
"name": "nhs-notify-default", | ||
"target": "branch", | ||
"enforcement": "active", | ||
"conditions": { | ||
"ref_name": { | ||
"exclude": [], | ||
"include": [ | ||
"~DEFAULT_BRANCH" | ||
] | ||
} | ||
}, | ||
"rules": [ | ||
{ | ||
"type": "deletion" | ||
}, | ||
{ | ||
"type": "non_fast_forward" | ||
}, | ||
{ | ||
"type": "required_signatures" | ||
}, | ||
{ | ||
"type": "pull_request", | ||
"parameters": { | ||
"required_approving_review_count": 1, | ||
"dismiss_stale_reviews_on_push": true, | ||
"require_code_owner_review": true, | ||
"require_last_push_approval": true, | ||
"required_review_thread_resolution": true | ||
} | ||
} | ||
] | ||
}' |