Skip to content

Instantly share code, notes, and snippets.

@michalvavra
Created May 16, 2024 13:46
Show Gist options
  • Select an option

  • Save michalvavra/ab1e34c454e2fb31b3fcc9bbcd6f77ab to your computer and use it in GitHub Desktop.

Select an option

Save michalvavra/ab1e34c454e2fb31b3fcc9bbcd6f77ab to your computer and use it in GitHub Desktop.
Ignore all GitHub org repos
#!/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