Created
January 7, 2018 18:06
-
-
Save kljensen/87298251b01d7145fef74b5881079468 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Call this with something like `PAGE=4 ./clone-all.sh my-org-name` | |
# Expects to find an environment variable and loads a .env file if | |
# it finds it in `cwd`. | |
if [ -z "$1" ] | |
then | |
echo "You must supply an organization name"; | |
exit 1; | |
fi | |
# Substitute variables here | |
ORG_NAME=$1 | |
GITHUB_INSTANCE="api.github.com" | |
# Source environment variables, overrides the | |
# defaults above and also expects to find ACCESS_TOKEN | |
set -a | |
. ./.env | |
set +a | |
if [ -z "$1" ] | |
then | |
echo "You must supply an ACCESS_TOKEN environment variable"; | |
exit 1; | |
fi | |
URL="https://${GITHUB_INSTANCE}/orgs/${ORG_NAME}/repos?per_page=100" | |
if [ ! -z "$PAGE" ] | |
then | |
URL="${URL}&page=${PAGE}" | |
fi | |
curl -H "Authorization: token ${ACCESS_TOKEN}" ${URL} \ | |
| jq '.[].ssh_url' -r \ | |
| parallel --jobs 2 git clone '{}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment