Skip to content

Instantly share code, notes, and snippets.

@madchap
Last active April 11, 2022 18:52
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save madchap/5f81e4636a91fe7368921eeb507d8721 to your computer and use it in GitHub Desktop.
Save madchap/5f81e4636a91fe7368921eeb507d8721 to your computer and use it in GitHub Desktop.
Unwatch all github repos from organization (unsubscribe)
# get api token with proper perms, ensure full "repos" for private repo access.
$ export auth="Authorization: token 123345465hfghfghfghgfhgfhfg"
$ export org="your_org"
# get the last page in the Link header. github API limits per_page to 100. Anything over this will require pagination.
$ curl -I -H "$auth" https://api.github.com/orgs/$org/repos
# go over all pages. Put this in a script, and save it.
#!/bin/bash
set -xe
for page in $(seq 1 5); do
echo "Processing page $page."
curl -H "$auth" https://api.github.com/orgs/$org/repos?page=$page |jq -r '.[] | .full_name' |
# curl -H "$auth" https://api.github.com/user/repos?page=$page |jq -r '.[] | .full_name' |
while read repo; do
curl -w "%{http_code}" -H "$auth" https://api.github.com/repos/$repo/subscription -XDELETE ;
done
done
# expect some 204 popping up, that's normal.
# Check github.com/watching to see if it's doing the job.
@feocco
Copy link

feocco commented Apr 4, 2019

🙇 thanks for saving me time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment