Created
October 24, 2023 16:51
-
-
Save btmash/6d9d16cae9723806536504b5f4ba0864 to your computer and use it in GitHub Desktop.
Get all repos from AWS Codecommit (with optional capability to use parallel if your system has it)
This file contains 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 | |
REPOSITORIES=$(aws codecommit list-repositories --sort-by repositoryName --query 'repositories[].repositoryName' --output text) | |
if ! command -v parallel &> /dev/null | |
then | |
for REPO in $REPOSITORIES | |
do | |
bash ./get_repo.sh $REPO | |
done | |
else | |
parallel -j 4 bash ./get_repo.sh {} ::: $REPOSITORIES | |
fi |
This file contains 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 | |
if [ -z "$1" ]; | |
then | |
echo 'No repository name supplied' | |
exit 1 | |
fi | |
REPO=$1 | |
echo $REPO | |
DETAILS=$(aws codecommit get-repository --repository-name $REPO) | |
REPONAME=$(echo $DETAILS | jq '.repositoryMetadata.repositoryName' | tr -d '"') | |
REPO_SSH_PATH=$(echo $DETAILS | jq '.repositoryMetadata.cloneUrlSsh' | tr -d '"') | |
rm -rf $REPONAME | |
git clone $REPO_SSH_PATH $REPONAME | |
echo $REPONAME | |
echo $REPO_SSH_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment