Forked from tiesmaster/disable-branch-protection.sh
Created
October 22, 2022 04:39
-
-
Save pas256/09a645fe15ee42185555cf176720c396 to your computer and use it in GitHub Desktop.
Enable/disable branch protection on GitHub through their API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OAUTH2_TOKEN=<fill in your own OAUTH2 token> | |
OWNER=tiesmaster | |
REPO=Coolkit.Converters # retrieve this with: basename $(git config --get remote.origin.url) .git | |
curl https://api.github.com/repos/${OWNER}/${REPO}/branches/master \ | |
-H "Authorization: token $OAUTH2_TOKEN" \ | |
-H "Accept: application/vnd.github.loki-preview+json" \ | |
-X PATCH \ | |
-d '{ | |
"protection": { | |
"enabled": false | |
} | |
}' \ | |
-s | json protection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OAUTH2_TOKEN=<fill in your own OAUTH2 token> | |
OWNER=tiesmaster | |
REPO=Coolkit.Converters # retrieve this with: basename $(git config --get remote.origin.url) .git | |
curl https://api.github.com/repos/${OWNER}/${REPO}/branches/master \ | |
-H "Authorization: token $OAUTH2_TOKEN" \ | |
-H "Accept: application/vnd.github.loki-preview+json" \ | |
-X PATCH \ | |
-d '{ | |
"protection": { | |
"enabled": true, | |
"required_status_checks": { | |
"enforcement_level": "everyone", | |
"contexts": [ | |
"default" | |
] | |
} | |
} | |
}' \ | |
-s | json protection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment