Add gh_mirror_org.sh

This commit is contained in:
h3artbl33d 2024-05-10 13:25:43 +02:00
parent 83bce6c2cc
commit be3c479ad3

28
scripts/gh_mirror_org.sh Normal file
View File

@ -0,0 +1,28 @@
#!/usr/local/bin/zsh
######################################################
# Mirror all repositories from a Github organisation #
######################################################
org="$1"
if [ -z $org ]; then
echo "Usage: $0 <organisation>"
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