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 policy issue #571

Open
bheemvennapureddy opened this issue Dec 15, 2023 · 2 comments
Open

Branch policy issue #571

bheemvennapureddy opened this issue Dec 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@bheemvennapureddy
Copy link
Contributor

branch policies have issue if you .github/settings doesn't have the same branch as repo.yml

ERROR (event): Error applying branch protection {"name":"HttpError","status":422,"response":{"url":"https://api.github.com/repos/CuroFinTechCorp/Web/branches/release%2F2324.0/protection","status":422,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-length":"340","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Fri, 15 Dec 2023 06:35:50 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"GitHub.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-github-permissions":"administration=write","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-api-version-selected":"2022-11-28","x-github-media-type":"github.v3; param=hellcat-preview.luke-cage-preview.zzzax-preview; format=json","x-github-request-id":"4D63:8AFE:27B0520:5243F58:657BF3C6","x-ratelimit-limit":"15000","x-ratelimit-remaining":"9397","x-ratelimit-reset":"1702623448","x-ratelimit-resource":"core","x-ratelimit-used":"5603","x-xss-protection":"0"},"data":{"message":"Invalid request.\n\nNo subschema in \"anyOf\" matched.\nNo subschema in \"oneOf\" matched.\nNot all subschemas of \"allOf\" matched.\nFor 'anyOf/1', {\"contexts\"=>[\"Web - Checkin\", \"validate_work_item\"]} is not a null.","documentation_url":"https://docs.github.com/rest/branches/branch-protection#update-branch-protection"}},"request":{"method":"PUT","url":"https://api.github.com/repos/CuroFinTechCorp/Web/branches/release%2F2324.0/protection","headers":{"accept":"application/vnd.github.hellcat-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.zzzax-preview+json","user-agent":"probot/12.3.1 octokit-core.js/3.5.1 Node.js/21","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":"{\"required_pull_request_reviews\":{\"required_approving_review_count\":2},\"required_status_checks\":{\"contexts\":[\"Web - Checkin\",\"validate_work_item\"]},\"enforce_admins\":true,\"restrictions\":{\"apps\":[\"curo-bot\"],\"teams\":[],\"users\":[]}}","request":{"retryCount":1}}}
0|safesettings  | 2023-12-15T06:35:50:     id: "2d45bba0-9b14-11ee-9186-75ad40e095c3"
@bheemvennapureddy bheemvennapureddy added the bug Something isn't working label Dec 15, 2023
@bheemvennapureddy
Copy link
Contributor Author

@decyjphr do we need to have .github/settings.yml all the time ? can we just enforce policies with .github/repos/*.yml

@svg153
Copy link
Contributor

svg153 commented Dec 16, 2023

The settings file is a general file that would apply this protection to all the organization's repositories. If there are repositories that do not have that branch name, you have to reset it to empty in the specific repo file (I don't know if it would also work in the suborg file) and add a new element with the protection configuration of that branch to that specific repository. This will cause the general branch to be deleted from the configuration and only the branch of that repository to be added. This is because by default what the configuration does is add all the configurations that exist.

I remember a similar question and it was explained how to do it. I don't know if it is already in the documentation or it was left as a comment in some issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants