Last active
October 31, 2024 22:26
-
-
Save zhilyaev/5ec431ae9928b94c063d6a574a69b111 to your computer and use it in GitHub Desktop.
gitlab-cloner.sh
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
| #!/usr/bin/env bash | |
| HOST_API="gitlab.com" | |
| TOKEN="<token>" | |
| fullPath="<path>" | |
| q="{group (fullPath: \"$fullPath\") {projects(includeSubgroups: true) {nodes {sshUrlToRepo}}}}" | |
| # brew install httpie | |
| repos=`https -A bearer -a $TOKEN -b https://$HOST_API/api/graphql query="$q" \ | |
| | jq ".data.group.projects.nodes.[].sshUrlToRepo" | tr -d \"` | |
| for repo in $repos; do | |
| dir=$(echo $repo | awk -F ":" '{print substr($2, 1, length($2)-4)}') | |
| mkdir -p $dir | |
| git clone --depth 1 $repo $dir | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment