Skip to content

Instantly share code, notes, and snippets.

@andreyev
Last active June 5, 2025 14:46
Show Gist options
  • Save andreyev/5230a387ba343d103d9b414be2215a55 to your computer and use it in GitHub Desktop.
Save andreyev/5230a387ba343d103d9b414be2215a55 to your computer and use it in GitHub Desktop.
gh-update.sh
#!/bin/bash
set -e
THIS_ORG=$(cat .org_name)
for VAR in GH_TOKEN THIS_ORG; do
test -v ${!VAR} && ( echo "$VAR not set, exiting..."; exit 1)
done
[[ -d repos ]] || mkdir 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 repos/$(basename $REPO) ]]; then
cd repos/$(basename $REPO) && git pull
cd -
else
cd repos
git clone [email protected]:${THIS_ORG}/${REPO}.git
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment