Skip to content

Instantly share code, notes, and snippets.

@syuraj
Created December 16, 2023 02:59
Show Gist options
  • Save syuraj/7bbebc304d02b4edd59f43551b96c97d to your computer and use it in GitHub Desktop.
Save syuraj/7bbebc304d02b4edd59f43551b96c97d to your computer and use it in GitHub Desktop.
remove_github_stars.sh
#!/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