Skip to content

Instantly share code, notes, and snippets.

@Skarlso
Created June 7, 2018 14:19
Show Gist options
  • Save Skarlso/ad116ec63f646eca2cf4095acc343fa7 to your computer and use it in GitHub Desktop.
Save Skarlso/ad116ec63f646eca2cf4095acc343fa7 to your computer and use it in GitHub Desktop.
Update all forks
#!/bin/bash
temp=`basename $0`
TMPFILE=`mktemp /tmp/${temp}.XXXXXX` || exit 1
API_CALL="/user/repos?type=owner+fork=true"
function rest_call {
curl -u skarlso:$GIT_TOKEN -s $1 >> $TMPFILE
}
last_page=`curl -u skarlso:$GIT_TOKEN -s -I "https://api.github.com$API_CALL" | grep '^Link:' | sed -e 's/^Link:.*page=//g' -e 's/>.*$//g'`
if [ -z "$last_page" ]; then
rest_call "https://api.github.com$API_CALL"
else
for p in `seq 1 $last_page`; do
rest_call "https://api.github.com$API_CALL?page=$p"
done
fi
cat $TMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment