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

Branch protection rules not applying in private repositories #107

Open
thejimbirch opened this issue Feb 10, 2024 · 0 comments
Open

Branch protection rules not applying in private repositories #107

thejimbirch opened this issue Feb 10, 2024 · 0 comments

Comments

@thejimbirch
Copy link

Hi,

Thanks for the cool tool.

However, I can't get the branch rules to apply in a private repository. I did not test in a public repository.

I see it in the code here:

    if [ -d "${APP_CONFIG}/branch-protection" ]; then
        for filepath in "${APP_CONFIG}/branch-protection/"*; do
            branch=$(basename "${filepath}" ".json")
            log:api "${repo}" "Configuring branch protection rules for '${branch}'"
            "${_GH}" api -X PUT "/repos/:owner/:repo/branches/${branch}/protection" \
                --input="${filepath}" >/dev/null
        done
    fi

But in the API docs, there is no GitHub CLI access, only cURL and JavaScript, so I am wondering it if would work on any repo public or private.

https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2022-11-28#update-branch-protection

For anyone else reading this, I used the cURL command to configure the repo like this:

curl -L \
  -X PUT \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/{org}/{repo}/branches/{branch}/protection \
  -d '{JSON}'
thejimbirch added a commit to kanopi/drupal-starter that referenced this issue Feb 10, 2024
Note: This file is not currently being used in gh-repo-config until twelvelabs/gh-repo-config#107 is fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant