From aeb574980b7f7d81cfc700d77fe0d23516e17a89 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 9 May 2026 19:15:02 -0500 Subject: [PATCH] feat: auto-discover all repos with wikis across all orgs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No more hardcoded repo list — queries Gitea API for all orgs and repos that have wikis enabled. Falls back to hardcoded list if no GITEA_TOKEN is set. Authored-by: Moko Consulting --- scripts/sync-wikis-to-github.sh | 60 ++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/scripts/sync-wikis-to-github.sh b/scripts/sync-wikis-to-github.sh index 1c3ccfb..1d45498 100644 --- a/scripts/sync-wikis-to-github.sh +++ b/scripts/sync-wikis-to-github.sh @@ -35,19 +35,53 @@ if [[ -z "$GH_TOKEN" ]]; then exit 1 fi -# Repo mappings: gitea_owner/repo → display name -declare -A REPOS=( - ["MokoConsulting/moko-platform"]="moko-platform" - ["MokoConsulting/MokoOnyx"]="MokoOnyx" - ["MokoConsulting/MokoWaaS"]="MokoWaaS" - ["MokoConsulting/monitor-mcp"]="monitor-mcp" - ["MokoConsulting/deploy-mcp"]="deploy-mcp" - ["MokoConsulting/ssh-mcp"]="ssh-mcp" - ["MokoConsulting/backup-mcp"]="backup-mcp" - ["MokoConsulting/joomla-api-mcp"]="joomla-api-mcp" - ["MokoConsulting/Template-Client-WaaS"]="Template-Client-WaaS" - ["ClarksvilleFurs/client-waas-clarksvillefurs"]="client-clarksvillefurs" -) +# Auto-discover repos with wikis from Gitea API +GITEA_TOKEN="${GITEA_TOKEN:-$(cat ~/.gitea-token 2>/dev/null || echo "")}" +declare -A REPOS=() + +if [[ -n "$GITEA_TOKEN" ]]; then + log "Auto-discovering repos with wikis..." + for ORG in MokoConsulting ClarksvilleFurs; do + PAGE=1 + while true; do + RESPONSE=$(curl -sf -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_URL}/api/v1/orgs/${ORG}/repos?page=${PAGE}&limit=50" 2>/dev/null) + [[ -z "$RESPONSE" || "$RESPONSE" == "[]" ]] && break + + REPO_LIST=$(echo "$RESPONSE" | python3 -c " +import sys, json +repos = json.load(sys.stdin) +for r in repos: + if r.get('has_wiki') and not r.get('archived'): + name = r['name'] + owner = r['owner']['login'] + print(f'{owner}/{name}|{name}') +" 2>/dev/null) + + while IFS='|' read -r full_name display; do + [[ -n "$full_name" ]] && REPOS["$full_name"]="$display" + done <<< "$REPO_LIST" + + PAGE=$((PAGE + 1)) + [[ $(echo "$RESPONSE" | python3 -c "import sys,json; print(len(json.load(sys.stdin)))" 2>/dev/null) -lt 50 ]] && break + done + done + log "Found ${#REPOS[@]} repos with wikis" +else + # Fallback to hardcoded list + REPOS=( + ["MokoConsulting/moko-platform"]="moko-platform" + ["MokoConsulting/MokoOnyx"]="MokoOnyx" + ["MokoConsulting/MokoWaaS"]="MokoWaaS" + ["MokoConsulting/monitor-mcp"]="monitor-mcp" + ["MokoConsulting/deploy-mcp"]="deploy-mcp" + ["MokoConsulting/ssh-mcp"]="ssh-mcp" + ["MokoConsulting/backup-mcp"]="backup-mcp" + ["MokoConsulting/joomla-api-mcp"]="joomla-api-mcp" + ["MokoConsulting/Template-Client-WaaS"]="Template-Client-WaaS" + ["ClarksvilleFurs/client-waas-clarksvillefurs"]="client-clarksvillefurs" + ) +fi FILTER="${1:-}"