/disableAllActions.sh Secret
Created
February 14, 2021 20:14
Star
You must be signed in to star a gist
Disables GitHub Actions on all personally owned repos, with the GitHub REST API and `cmonr/gh` tool.
This file contains 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
#!/usr/bin/env bash | |
# Author: Cruz Monrreal II | |
set -eufo pipefail | |
gh --paginate get "/user/repos?affiliation=owner" \ | |
| jq -r '.[] | .full_name' \ | |
| while read -r ghRepo; do | |
printf "'%s': " "${ghRepo}" | |
read -r isEnabled < <( \ | |
gh get "/repos/${ghRepo}/actions/permissions" \ | |
| jq -r '.enabled' | |
) | |
printf "\e[1m%s\e[0m" "${isEnabled}" | |
if [[ "${isEnabled}" == "true" ]]; then | |
gh put \ | |
"/repos/${ghRepo}/actions/permissions" \ | |
'{"enabled":false}' \ | |
&& printf "\e[4D\e[1m%s\e[0m" "DISABLED" | |
fi | |
printf "\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment