Created
May 16, 2024 13:46
-
-
Save michalvavra/ab1e34c454e2fb31b3fcc9bbcd6f77ab to your computer and use it in GitHub Desktop.
Ignore all GitHub org repos
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
| #!/usr/bin/env bash | |
| set -eo pipefail | |
| # Usage: sh ignore-all-org-repos.sh ORG_NAME | |
| if ! [ -x "$(command -v gh)" ]; then | |
| echo >&2 "Error: gh is not installed." | |
| exit 1 | |
| fi | |
| if ! [ -x "$(command -v jq)" ]; then | |
| echo >&2 "Error: jq is not installed." | |
| exit 1 | |
| fi | |
| org=$1 | |
| max_repos=5000 | |
| org_repos=$(gh repo list $org -L $max_repos --json name --jq '.[].name') | |
| for repo in $org_repos; do | |
| echo -e "Unsubscribing from $org/$repo\n" | |
| gh api -H "Accept: application/vnd.github+json" /repos/$org/$repo/subscription --method PUT -f ignored=true | jq '.' | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment