When executing the script,
we get the following errors :
"Invalid request.\n\nNo subschema in \"anyOf\" matched.\n\"restrictions\" wasn't supplied.\nFor 'items', \"lint-test / lint-test\" is not an object.\nNot all subschemas of \"allOf\" matched.\nFor 'anyOf/1', {\"strict\"=>true, \"checks\"=>[\"lint-test / lint-test\"]} is not a null.",
"documentation_url": "https://docs.github.com/rest/branches/branch-protection#update-branch-protection"
Looking at the documentation, required_status_checks requires a "context" key and not a "checks" key
We are also not getting all existing repositories when we do :
API_URL="https://api.github.com/orgs/${ORG_NAME}/repos?type=public"
# get list of all public repos
RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${API_URL}")
REPOS=$(echo "${RESPONSE}" | jq -r '.[].full_name')
since GitHub's API paginates the responses. If we have more repositories than the default per-page limit (usually 30), not all repositories will be returned in a single API call.
When executing the script, we get the following errors :
Looking at the documentation, required_status_checks requires a "context" key and not a "checks" key
Also, we are missing a comma at the end of "require_code_owner_reviews": true :
Which results in error parsing JSON.
We are also not getting all existing repositories when we do :
since GitHub's API paginates the responses. If we have more repositories than the default per-page limit (usually 30), not all repositories will be returned in a single API call.