Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As a Devops, I would like to be able to use the script to automate branch protection ruleset #33

Closed
SonOfLope opened this issue Mar 6, 2024 · 0 comments · Fixed by #34
Assignees

Comments

@SonOfLope
Copy link
Contributor

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

       "required_status_checks": {
            "strict": true,
            "checks": ["lint-test / lint-test"]
        },

Also, we are missing a comma at the end of "require_code_owner_reviews": true :

        "required_pull_request_reviews": {
            "required_approving_review_count": 1,
            "require_code_owner_reviews": true
        },

Which results in error parsing JSON.

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.

@SonOfLope SonOfLope self-assigned this Mar 6, 2024
@SonOfLope SonOfLope changed the title Error using branch-protection-ruleset.sh script As a Devops, I would like to be able to use the script to automate branch protection ruleset Mar 6, 2024
@SonOfLope SonOfLope linked a pull request Mar 6, 2024 that will close this issue
1 task
SonOfLope added a commit that referenced this issue Mar 6, 2024
@SonOfLope SonOfLope moved this to In Progress in DevSecOps Mar 6, 2024
SonOfLope added a commit that referenced this issue Mar 6, 2024
…stead of file and handle commits based on existing file or not
SonOfLope added a commit that referenced this issue Mar 6, 2024
…-able-to-use-the-script-to-automate-branch-protection-ruleset

Issue #33: Hotfix for branch protection ruleset script
@github-project-automation github-project-automation bot moved this from In Progress to Done in DevSecOps Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant