Last active
April 11, 2022 18:52
-
-
Save madchap/5f81e4636a91fe7368921eeb507d8721 to your computer and use it in GitHub Desktop.
Unwatch all github repos from organization (unsubscribe)
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
# 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🙇 thanks for saving me time