Skip to content

Commit 7e11380

Browse files
greynewellclaude
andcommitted
Fix sync-repos yq empty string bug; add _redirects proxy for community repos
- sync-repos.yml: use strenv() instead of env() for PILL/PILL_CLASS to handle empty strings (fixes failure when language is MDX or unknown) - generate-index.go: generate site/_redirects with Cloudflare Pages proxy rules routing /{repo}/* → supermodeltools.github.io/{repo}/:splat for community repos (those with upstream field and no local arch-docs) - setup-community-repos.sh: use GitHub Pages workflow (no BOT_TOKEN needed), update repos list to match current repos.yaml, remove SUPERMODEL_API_KEY env requirement (it's an org-level secret) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7938534 commit 7e11380

File tree

3 files changed

+70
-60
lines changed

3 files changed

+70
-60
lines changed

.github/workflows/sync-repos.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ jobs:
9696
"name": env(REPO_NAME),
9797
"upstream": env(UPSTREAM),
9898
"description": env(DESCRIPTION),
99-
"pill": env(PILL),
100-
"pill_class": env(PILL_CLASS)
99+
"pill": strenv(PILL),
100+
"pill_class": strenv(PILL_CLASS)
101101
}]' repos.yaml
102102
else
103103
# Append to Supermodel Open Source category (index 0)
@@ -108,8 +108,8 @@ jobs:
108108
yq -i '.categories[0].repos += [{
109109
"name": env(REPO_NAME),
110110
"description": env(DESCRIPTION),
111-
"pill": env(PILL),
112-
"pill_class": env(PILL_CLASS)
111+
"pill": strenv(PILL),
112+
"pill_class": strenv(PILL_CLASS)
113113
}]' repos.yaml
114114
fi
115115

generate-index.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ func main() {
5959
os.Exit(1)
6060
}
6161

62+
// generateRedirects must run before generateRepoPages so placeholder
63+
// index.html files don't exist yet when we check for local arch-docs.
64+
if err := generateRedirects(cfg); err != nil {
65+
fmt.Fprintf(os.Stderr, "Error generating _redirects: %v\n", err)
66+
os.Exit(1)
67+
}
68+
6269
if err := generateRepoPages(cfg); err != nil {
6370
fmt.Fprintf(os.Stderr, "Error generating repo pages: %v\n", err)
6471
os.Exit(1)
@@ -141,6 +148,27 @@ func generateRepoPages(cfg Config) error {
141148
return nil
142149
}
143150

151+
func generateRedirects(cfg Config) error {
152+
var b strings.Builder
153+
for _, cat := range cfg.Categories {
154+
for _, repo := range cat.Repos {
155+
if repo.Upstream == "" {
156+
continue // supermodel repos use centralized site/ subdirectories
157+
}
158+
// Check if arch-docs are already deployed locally (centralized approach)
159+
if _, err := os.Stat(fmt.Sprintf("site/%s/index.html", url.PathEscape(repo.Name))); err == nil {
160+
continue // has local arch-docs, no proxy needed
161+
}
162+
b.WriteString(fmt.Sprintf("/%s/* https://supermodeltools.github.io/%s/:splat 200\n",
163+
url.PathEscape(repo.Name), url.PathEscape(repo.Name)))
164+
}
165+
}
166+
if b.Len() == 0 {
167+
return nil
168+
}
169+
return os.WriteFile("site/_redirects", []byte(b.String()), 0644)
170+
}
171+
144172
func generateIndex(cfg Config) error {
145173
tmpl, err := template.New("index").Funcs(template.FuncMap{
146174
"escape": html.EscapeString,

setup-community-repos.sh

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,33 @@
44
# Fork community repos into supermodeltools org, set up arch-docs workflow,
55
# enable GitHub Pages, and trigger the first build.
66
#
7+
# Community repos deploy arch-docs to GitHub Pages at supermodeltools.github.io/{repo}/
8+
# The central site proxies those paths via Cloudflare Pages _redirects.
9+
#
710
# Prerequisites:
811
# - gh CLI authenticated with supermodeltools org admin access
9-
# - SUPERMODEL_API_KEY environment variable set
12+
# - SUPERMODEL_API_KEY is available as an org-level secret (no local env needed)
1013
#
1114
# Usage:
12-
# SUPERMODEL_API_KEY=sk-... ./setup-community-repos.sh
15+
# ./setup-community-repos.sh
1316

1417
set -euo pipefail
1518

16-
if [ -z "${SUPERMODEL_API_KEY:-}" ]; then
17-
echo "Error: SUPERMODEL_API_KEY environment variable is required"
18-
exit 1
19-
fi
20-
2119
ORG="supermodeltools"
2220

21+
# Community repos from repos.yaml (upstream → fork name)
2322
REPOS=(
24-
"facebook/react"
25-
"vercel/next.js"
2623
"vuejs/vue"
27-
"sveltejs/svelte"
28-
"expressjs/express"
29-
"fastify/fastify"
30-
"pallets/flask"
31-
"django/django"
32-
"golang/go"
33-
"rust-lang/rust"
34-
"denoland/deno"
3524
"oven-sh/bun"
36-
"langchain-ai/langchain"
37-
"huggingface/transformers"
38-
"anthropics/anthropic-sdk-python"
25+
"tiangolo/fastapi"
26+
"gin-gonic/gin"
27+
"spring-projects/spring-boot"
28+
"pytorch/pytorch"
3929
"supabase/supabase"
40-
"drizzle-team/drizzle-orm"
4130
"tailwindlabs/tailwindcss"
42-
"shadcn-ui/ui"
43-
"astro-build/astro"
4431
)
4532

33+
# GitHub Pages deployment workflow (no BOT_TOKEN needed)
4634
WORKFLOW_CONTENT='name: Architecture Docs
4735
4836
on:
@@ -52,10 +40,19 @@ on:
5240
5341
permissions:
5442
contents: read
43+
pages: write
44+
id-token: write
45+
46+
concurrency:
47+
group: pages
48+
cancel-in-progress: true
5549
5650
jobs:
5751
build-and-deploy:
5852
runs-on: ubuntu-latest
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deploy.outputs.page_url }}
5956
steps:
6057
- uses: actions/checkout@v4
6158
@@ -65,27 +62,14 @@ jobs:
6562
supermodel-api-key: ${{ secrets.SUPERMODEL_API_KEY }}
6663
base-url: https://repos.supermodeltools.com
6764
68-
- name: Deploy to central site
69-
env:
70-
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
71-
REPO_NAME: ${{ github.event.repository.name }}
72-
run: |
73-
git config --global user.name "supermodel-bot"
74-
git config --global user.email "bot@supermodeltools.com"
75-
git clone https://x-access-token:${BOT_TOKEN}@github.com/GraphTechnologyDevelopers/graphtechnologydevelopers.github.io.git central-site
76-
rm -rf central-site/site/${REPO_NAME}
77-
mkdir -p central-site/site/${REPO_NAME}
78-
cp -r arch-docs-output/. central-site/site/${REPO_NAME}/
79-
cd central-site
80-
git add site/${REPO_NAME}/
81-
git diff --staged --quiet && echo "No changes" && exit 0
82-
git commit -m "Deploy arch-docs for ${REPO_NAME}"
83-
for i in 1 2 3 4 5; do
84-
git push && break
85-
echo "Push failed, retrying in ${i}0s..."
86-
sleep $((i * 10))
87-
git pull --rebase origin main
88-
done'
65+
- uses: actions/configure-pages@v5
66+
67+
- uses: actions/upload-pages-artifact@v3
68+
with:
69+
path: ./arch-docs-output
70+
71+
- uses: actions/deploy-pages@v4
72+
id: deploy'
8973

9074
for UPSTREAM in "${REPOS[@]}"; do
9175
REPO_NAME="${UPSTREAM##*/}"
@@ -99,20 +83,16 @@ for UPSTREAM in "${REPOS[@]}"; do
9983
else
10084
echo " Forking ${UPSTREAM} into ${ORG}..."
10185
gh repo fork "${UPSTREAM}" --org "${ORG}" --clone=false
102-
sleep 2
86+
sleep 3
10387
fi
10488

105-
# 2. Set the SUPERMODEL_API_KEY secret
106-
echo " Setting SUPERMODEL_API_KEY secret..."
107-
gh secret set SUPERMODEL_API_KEY --repo "${FORK}" --body "${SUPERMODEL_API_KEY}"
108-
109-
# 3. Detect default branch
89+
# 2. Detect default branch
11090
DEFAULT_BRANCH=$(gh api "repos/${FORK}" --jq '.default_branch')
11191
echo " Default branch: ${DEFAULT_BRANCH}"
11292

113-
# 4. Push the arch-docs workflow file
93+
# 3. Push the arch-docs workflow file
11494
echo " Creating arch-docs workflow..."
115-
ENCODED=$(echo -n "${WORKFLOW_CONTENT}" | base64)
95+
ENCODED=$(printf '%s' "${WORKFLOW_CONTENT}" | base64 | tr -d '\n')
11696

11797
# Check if workflow already exists
11898
EXISTING_SHA=$(gh api "repos/${FORK}/contents/.github/workflows/arch-docs.yml" --jq '.sha' 2>/dev/null || echo "")
@@ -132,7 +112,7 @@ for UPSTREAM in "${REPOS[@]}"; do
132112
--silent
133113
fi
134114

135-
# 5. Enable GitHub Pages with Actions as source
115+
# 4. Enable GitHub Pages with Actions as source
136116
echo " Enabling GitHub Pages..."
137117
gh api --method POST "repos/${FORK}/pages" \
138118
-f build_type="workflow" \
@@ -142,14 +122,16 @@ for UPSTREAM in "${REPOS[@]}"; do
142122
--silent 2>/dev/null || \
143123
echo " (Pages may already be configured)"
144124

145-
# 6. Trigger the workflow
125+
# 5. Trigger the workflow
146126
echo " Triggering arch-docs workflow..."
127+
sleep 2 # brief pause for workflow file to propagate
147128
gh workflow run arch-docs.yml --repo "${FORK}" --ref "${DEFAULT_BRANCH}" 2>/dev/null || \
148-
echo " (Workflow trigger may need a moment, try manually if needed)"
129+
echo " (Workflow trigger may need a moment — trigger manually if needed)"
149130

150131
echo " Done: ${FORK}"
151132
echo ""
152133
done
153134

154135
echo "=== All community repos set up! ==="
155-
echo "Docs will deploy at repos.supermodeltools.com/{repo}/ as workflows complete."
136+
echo "Arch-docs will deploy to supermodeltools.github.io/{repo}/ as workflows complete."
137+
echo "The central site at repos.supermodeltools.com/{repo}/ will proxy there via _redirects."

0 commit comments

Comments
 (0)