From fd464090c4a230d5c1f713a938935c82be4d8ac9 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 22 May 2024 09:38:41 +0100 Subject: [PATCH 1/5] added default branch protection script. --- .github/README.md | 11 ++++++++++ .github/branch-protection.sh | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/README.md create mode 100755 .github/branch-protection.sh diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 0000000..cd2be5d --- /dev/null +++ b/.github/README.md @@ -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 diff --git a/.github/branch-protection.sh b/.github/branch-protection.sh new file mode 100755 index 0000000..c359d8c --- /dev/null +++ b/.github/branch-protection.sh @@ -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 + } + } + ] +}' From e109fe0cef2443556592bfe851c1d609859f11bf Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 22 May 2024 10:14:19 +0100 Subject: [PATCH 2/5] add github to allowed words. --- .github/README.md | 6 +++--- scripts/config/vale/styles/Vocab/words/accept.txt | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index cd2be5d..1821a1c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -2,10 +2,10 @@ ## Branch Protection Rules -This will create the default branch protection rules using github API. +This will create the default branch protection rules using Github API. -``` +```sh ./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 +PAT must have `administration:write`. [Create a repository rule set](https://docs.github.com/en/rest/repos/rules?apiVersion=2022-11-28#create-a-repository-ruleset) diff --git a/scripts/config/vale/styles/Vocab/words/accept.txt b/scripts/config/vale/styles/Vocab/words/accept.txt index eb9cd04..dccae85 100644 --- a/scripts/config/vale/styles/Vocab/words/accept.txt +++ b/scripts/config/vale/styles/Vocab/words/accept.txt @@ -15,3 +15,4 @@ idempotence onboarding toolchain [A-Z]+s +Github From 77aaa467a302db6acc592ab540f64e244e2594d3 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 22 May 2024 10:20:18 +0100 Subject: [PATCH 3/5] test --- testing.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testing.md diff --git a/testing.md b/testing.md new file mode 100644 index 0000000..e69de29 From fbd26252588ec60220342080388507aade6d7004 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 22 May 2024 10:22:33 +0100 Subject: [PATCH 4/5] remove testing. --- testing.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 testing.md diff --git a/testing.md b/testing.md deleted file mode 100644 index e69de29..0000000 From 4309b59025102acc391c10b428a23c2eb807ac35 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 22 May 2024 10:24:02 +0100 Subject: [PATCH 5/5] Added default code owners. --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5be7aa5..d2827c8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,9 @@ # NHS Notify Code Owners +# Notify default owners +* @rossbugginsnhs @m-houston @edmundcraske2-nhs @timireland + +# Codeowners must be final check /.github/CODEOWNERS @NHSDigital/nhs-notify-code-owners /CODEOWNERS @NHSDigital/nhs-notify-code-owners