Skip to content

Instantly share code, notes, and snippets.

@cmonr
Created February 14, 2021 20:14
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cmonr/27d542eb0a33bde631c642707bb8bf92 to your computer and use it in GitHub Desktop.
Disables GitHub Actions on all personally owned repos, with the GitHub REST API and `cmonr/gh` tool.
#!/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