Skip to content

Instantly share code, notes, and snippets.

@nektro
Created September 29, 2020 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nektro/bdf37b3035ffc8567de5af105adb6e14 to your computer and use it in GitHub Desktop.
Save nektro/bdf37b3035ffc8567de5af105adb6e14 to your computer and use it in GitHub Desktop.
./get_github_user.sh <username>
#!/usr/bin/env bash
c1=1
c2=0
mkdir -p $1
cd $1
IFS=$'\n'
uid="$GITHUB_CLIENT"
sec="$GITHUB_SECRET"
while :
do
echo $c1
api_results=$(curl -s -u "$uid:$sec" https://api.github.com/users/$1/repos\?page=$c1 | jq --compact-output '.[]')
for line in $api_results
do
name=$(echo $line | jq --raw-output '.name')
echo "Cloning $1/$name..."
git clone -q "https://github.com/$1/$name"
c2=$(($c2+1))
done
if [[ "$c2" == '0' ]]; then
break
fi
c1=$(($c1+1))
c2=0
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment