Created
December 16, 2023 02:59
-
-
Save syuraj/7bbebc304d02b4edd59f43551b96c97d to your computer and use it in GitHub Desktop.
remove_github_stars.sh
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 | |
# source: https://gist.github.com/justlaputa/a6da84981eca963817e652b5f2452cfc | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
STARS_PAGE_COUNT=20 | |
STARS_FILE=stars.txt | |
DELETE_SLEEP_TIME=.5 | |
APIKEY="<copy personal access token from https://github.com/settings/tokens>" | |
function get_all_star_repos() { | |
for p in $(seq 1 $STARS_PAGE_COUNT);do | |
echo "page: $p" | |
curl -s -H "Authorization: token $APIKEY" https://api.github.com/user/starred\?page\=$p | jq -r '.[] |.full_name' >> $STARS_FILE | |
done | |
} | |
function remove_all_star_repos() { | |
while read REPO;do | |
echo "REPO: $REPO" | |
curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $APIKEY" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/user/starred/$REPO & | |
done < stars.txt | |
} | |
get_all_star_repos | |
remove_all_star_repos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment