Skip to content

Instantly share code, notes, and snippets.

@Hackdemon23
Forked from chrisdlangton/clone_all.sh
Created December 2, 2019 23:05
Show Gist options
  • Save Hackdemon23/a2ef2ae86477dad632a289be9bd8d599 to your computer and use it in GitHub Desktop.
Save Hackdemon23/a2ef2ae86477dad632a289be9bd8d599 to your computer and use it in GitHub Desktop.
Quick clone all org repos using Github Enterprise API v3
#!/usr/bin/env bash
prefix_url='https://github......'
declare -a groups=(
"my"
"org"
"groups"
)
CWD=$(pwd)
WORKDIR=${HOME}/workspace
mkdir -p ${WORKDIR}
cd ${WORKDIR}
for group in "${groups[@]}"
do
repos=$(wget -q --no-check-certificate ${prefix_url}/api/v3/orgs/${group}/repos -O- | jq -r '.[].name')
mkdir -p ${group}
cd ${group}
while read -r repo; do
if [[ ! -d ${repo} ]]; then
git clone ${prefix_url}/${group}/${repo}.git
fi
done <<< "${repos}"
cd ${WORKDIR}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment