Last active
June 27, 2022 14:24
-
-
Save cderv/eac2e630a4bde09dfbe0bd6d213140aa to your computer and use it in GitHub Desktop.
Update all repos from an organisation on github
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
$repos = gh repo list 'quarto-journals' --no-archived --source --json owner,name,defaultBranchRef -q '.[] | {org: .owner.login, repo: .name, branch: .defaultBranchRef.name}' | ConvertFrom-Json | |
foreach($row in $repos) { | |
echo "Looking for $($row.repo) folder" | |
if (Test-Path -Path $row.repo) { | |
git -C "$($row.repo)" checkout $row.branch | |
git -C "$($row.repo)" pull origin $row.branch | |
} else { | |
gh repo clone "$($row.org)/$($row.repo)" | |
} | |
} | |
echo "All repos updated!" |
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 | |
repos=$(gh repo list 'quarto-journals' --no-archived --source --json owner,name,defaultBranchRef -q '.[] | {org: .owner.login, repo: .name, branch: .defaultBranchRef.name}') | |
echo $repos | |
for row in $(echo "${repos}"); do | |
repo=$(echo ${row} | jq -r '.repo') | |
branch=$(echo ${row} | jq -r '.branch') | |
org=$(echo ${row} | jq -r '.org') | |
echo "Looking for ${repo} folder" | |
if [ -d "$repo" ]; then | |
git -C "$repo" checkout $branch | |
git -C "$repo" pull origin $branch | |
else | |
gh repo clone "${org}/${repo}" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment