Last active
April 22, 2025 08:37
-
-
Save Vincinator/943617eeaf523d797a7f16ceac5c8796 to your computer and use it in GitHub Desktop.
clone all gardenlinux package repos
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_NAME="gardenlinux" | |
REPO_PREFIX="package-" | |
# Authenticate with GitHub CLI (ensure you're logged in with `gh auth login`) | |
gh auth status > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "Please log in to GitHub CLI using 'gh auth login'." | |
exit 1 | |
fi | |
# Fetch repositories in the organization | |
repos=$(gh repo list "$ORG_NAME" --json name,sshUrl --jq ".[] | select(.name | startswith(\"$REPO_PREFIX\")) | .sshUrl") | |
# Loop through the repository SSH URLs and clone them | |
for repo in $repos; do | |
repo_name=$(basename "$repo" .git) # Extract repository name | |
if [ -d "$repo_name" ]; then | |
echo "Skipping $repo_name as it already exists." | |
else | |
echo "Cloning $repo_name..." | |
git clone "$repo" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment