Skip to content

Instantly share code, notes, and snippets.

@andreyev
Last active August 8, 2025 19:50
Show Gist options
  • Select an option

  • Save andreyev/5230a387ba343d103d9b414be2215a55 to your computer and use it in GitHub Desktop.

Select an option

Save andreyev/5230a387ba343d103d9b414be2215a55 to your computer and use it in GitHub Desktop.
gh-update.sh
#!/bin/bash
set -e
THIS_ORG=$(cat .org_name)
GIT_SERVER=$((test -f .git_server && cat .git_server) || echo github.com)
for VAR in GH_TOKEN THIS_ORG; do
test -v ${!VAR} && ( echo "$VAR not set, exiting..."; exit 1)
done
[[ -d repos ]] || mkdir repos && cd repos
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GH_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/$THIS_ORG/repos?per_page=100 | jq -r '.[].name' | while read REPO; do
[[ -f .deny_list ]] && grep -Eo "^${REPO}$" .deny_list && break
if [[ -d $(basename $REPO) ]]; then
cd $(basename $REPO) && git pull
cd -
else
git clone git@${GIT_SERVER}:${THIS_ORG}/${REPO}.git
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment