Created
August 7, 2023 05:09
-
-
Save cvan/dea237cd56ec8d3a2811df1a4218845c to your computer and use it in GitHub Desktop.
GitHub Org Archiver — using gh cli: https://cli.github.com
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 | |
NL=$'\n'; | |
output_dir="$HOME/ghq/github.com"; | |
repo_limit=100000; | |
org_slug="$1"; | |
echo "<\!doctype html><html><meta charset='utf-8'><title>$org_slug</title></head><body><code><pre>$(gh repo list $org_slug --limit $repo_limit)</pre></code></body></html>""$NL" > index.html | |
list=$(gh repo list $org_slug --json name --jq '.[].name') | |
for repo_slug in $(echo $list | cut -d$'\t' -f1); do | |
pushd $output_dir/$org_slug; | |
gh repo clone $org_slug/$repo_slug $repo_slug || (\ | |
pushd $repo_slug; \ | |
git fetch --all ; git pull; \ | |
popd; \ | |
) | |
# echo git clone https://github.com/$org_slug/$repo_slug.git $repo_slug | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment