diff --git a/scripts/gh_mirror_org.sh b/scripts/gh_mirror_org.sh new file mode 100644 index 0000000..fa54020 --- /dev/null +++ b/scripts/gh_mirror_org.sh @@ -0,0 +1,28 @@ +#!/usr/local/bin/zsh +###################################################### +# Mirror all repositories from a Github organisation # +###################################################### + +org="$1" + +if [ -z $org ]; then + echo "Usage: $0 " + exit 1 +fi + +mkdir -p $org +pushd $org + +for repo in $(curl -v -s "https://api.github.com/orgs/$org/repos?per_page=100&type=sources" 2>&1 | grep '"full_name": "*"' | cut -d':' -f2 | sed s'/,$//' | sed s'/"//g' ); do + + filename=$(echo "$repo" | cut -d'/' -f2) + if [ -e $filename ]; then + pushd $filename + git pull + popd + else + git clone https://github.com/$repo + fi +done + +popd