Created
March 19, 2019 16:25
-
-
Save Ithildir/dfd3071af375e7872444063afecc20df to your computer and use it in GitHub Desktop.
Clone all repositories in a GitHub organization
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 | |
ORG=XXX | |
GITHUB_USER=XXX | |
GITHUB_TOKEN=XXX | |
SEARCH_TERM='ssh_url' | |
SSH_REGEX='s#.*\(git*@[^"]*\).*#\1#;p' | |
function get_repos { | |
curl -s "https://api.github.com/orgs/${ORG}/repos?page=$1&per_page=100" -u ${GITHUB_USER}:${GITHUB_TOKEN} | grep ${SEARCH_TERM} | sed -e "${SSH_REGEX}" | |
} | |
echo "Starting to clone github org: ${ORG}'s repos" | |
for x in $(seq 1 100); do | |
repos=$(get_repos "${x}") | |
while read -r repo; do | |
if ! [[ "$repo" =~ /old- ]]; then | |
git clone "${repo}" | |
fi | |
done <<< "${repos}" | |
done | |
echo "Finished cloning ${ORG} repos" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment