kloeckner.com.ar

Backup of part of my webpage
Index Commits Files Refs README LICENSE
git/sync-repos (959B)
   1 #!/bin/sh
   2 
   3 set -xu
   4 
   5 BIN_DIR="/root/git"
   6 GIT_DIR="/var/www/git"
   7 GIT_SSH_COMMAND=''
   8 
   9 mkdir -p "$GIT_DIR"
  10 
  11 gh repo list --limit 1000 --json nameWithOwner,isPrivate,isFork \
  12     --jq '.[] | select(.isPrivate == false and .isFork == false) |
  13     .nameWithOwner' |
  14 while read -r repo; do
  15     name=$(basename "$repo")
  16     repo_dir="$GIT_DIR/$name"
  17     bare_repo_path="$repo_dir/$name.git"
  18 
  19     if [ -d "$repo_dir" ]; then
  20         git -C "$bare_repo_path" remote update --prune
  21     gh repo view $repo --json description --jq '.description' > \
  22         $bare_repo_path/description
  23     else
  24         mkdir -p "$repo_dir"
  25         git clone --mirror "https://github.com/$repo.git" "$bare_repo_path"
  26         gh repo view $repo --json description --jq '.description' > \
  27             $bare_repo_path/description
  28 
  29         ln -sf "$bare_repo_path" /home/git
  30     fi
  31 
  32     (cd "$GIT_DIR"; "$BIN_DIR"/update-git-repo "$repo_dir")
  33 done
  34 
  35 (cd "$GIT_DIR"; "$BIN_DIR"/generate-git-main-index .)