Skip to content

Commit 0834f37

Browse files
greynewellclaude
andcommitted
Centralize arch-docs deployment to eliminate Cloudflare Workers
Each repo's arch-docs workflow now pushes output directly to site/{name}/ in this central repo (with base-url set to repos.supermodeltools.com) instead of deploying to individual GitHub Pages. This means the full site — index, landing pages, and all deep arch-docs pages — lives at repos.supermodeltools.com with no Workers needed. Changes: - generate-index.go: fix sitemap to use urlset (not sitemapindex), skip generating landing pages for repos that already have arch-docs - build-index.yml: also trigger on site/** changes so a new arch-docs push redeploys the full site - setup-community-repos.sh: update workflow template with new approach - update-arch-docs-workflows.sh: new script to push updated workflow to all existing repos and set BOT_TOKEN secret To complete setup: 1. Create a PAT with contents:write on graphtechnologydevelopers.github.io 2. Run: BOT_TOKEN=ghp_... ./update-arch-docs-workflows.sh 3. Trigger each repo's arch-docs workflow to do initial deploys Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a36c939 commit 0834f37

File tree

4 files changed

+140
-23
lines changed

4 files changed

+140
-23
lines changed

.github/workflows/build-index.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ name: Build Index
33
on:
44
push:
55
branches: [main]
6-
paths: [repos.yaml, generate-index.go, go.mod, go.sum, .github/workflows/build-index.yml]
6+
paths:
7+
- repos.yaml
8+
- generate-index.go
9+
- go.mod
10+
- go.sum
11+
- .github/workflows/build-index.yml
12+
- site/**
713
workflow_dispatch:
814

915
permissions:

generate-index.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ func main() {
8282
func generateSitemap(cfg Config) error {
8383
var b strings.Builder
8484
b.WriteString(`<?xml version="1.0" encoding="UTF-8"?>` + "\n")
85-
b.WriteString(`<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">` + "\n")
85+
b.WriteString(`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">` + "\n")
86+
b.WriteString(fmt.Sprintf(" <url>\n <loc>%s/</loc>\n <priority>1.0</priority>\n </url>\n", baseURL))
8687
for _, cat := range cfg.Categories {
8788
for _, repo := range cat.Repos {
88-
b.WriteString(fmt.Sprintf(" <sitemap>\n <loc>%s/%s/sitemap.xml</loc>\n </sitemap>\n", baseURL, url.PathEscape(repo.Name)))
89+
b.WriteString(fmt.Sprintf(" <url>\n <loc>%s/%s/</loc>\n <priority>0.8</priority>\n </url>\n", baseURL, url.PathEscape(repo.Name)))
8990
}
9091
}
91-
b.WriteString("</sitemapindex>\n")
92+
b.WriteString("</urlset>\n")
9293
return os.WriteFile("site/sitemap.xml", []byte(b.String()), 0644)
9394
}
9495

@@ -119,6 +120,10 @@ func generateRepoPages(cfg Config) error {
119120
for _, cat := range cfg.Categories {
120121
for _, repo := range cat.Repos {
121122
dir := fmt.Sprintf("site/%s", url.PathEscape(repo.Name))
123+
// Skip if arch-docs have already been deployed to this directory
124+
if _, err := os.Stat(fmt.Sprintf("%s/index.html", dir)); err == nil {
125+
continue
126+
}
122127
if err := os.MkdirAll(dir, 0755); err != nil {
123128
return fmt.Errorf("creating dir %s: %w", dir, err)
124129
}

setup-community-repos.sh

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,41 @@ on:
5151
workflow_dispatch:
5252
5353
permissions:
54-
contents: write
55-
pages: write
56-
id-token: write
57-
58-
concurrency:
59-
group: pages
60-
cancel-in-progress: true
54+
contents: read
6155
6256
jobs:
6357
build-and-deploy:
6458
runs-on: ubuntu-latest
65-
environment:
66-
name: github-pages
67-
url: ${{ steps.deploy.outputs.page_url }}
6859
steps:
6960
- uses: actions/checkout@v4
7061
7162
- uses: supermodeltools/arch-docs@main
7263
id: docs
7364
with:
7465
supermodel-api-key: ${{ secrets.SUPERMODEL_API_KEY }}
75-
76-
- uses: actions/configure-pages@v5
77-
78-
- uses: actions/upload-pages-artifact@v3
79-
with:
80-
path: ./arch-docs-output
81-
82-
- uses: actions/deploy-pages@v4
83-
id: deploy'
66+
base-url: https://repos.supermodeltools.com
67+
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'
8489

8590
for UPSTREAM in "${REPOS[@]}"; do
8691
REPO_NAME="${UPSTREAM##*/}"

update-arch-docs-workflows.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env bash
2+
# update-arch-docs-workflows.sh
3+
#
4+
# Updates arch-docs.yml in all repos listed in repos.yaml to push output
5+
# to the central GraphTechnologyDevelopers/graphtechnologydevelopers.github.io
6+
# site instead of deploying to individual GitHub Pages.
7+
#
8+
# Prerequisites:
9+
# - gh CLI authenticated with supermodeltools org access
10+
# - BOT_TOKEN secret must be set on each repo (PAT with write access to
11+
# GraphTechnologyDevelopers/graphtechnologydevelopers.github.io)
12+
#
13+
# Usage:
14+
# BOT_TOKEN=ghp_... ./update-arch-docs-workflows.sh
15+
16+
set -euo pipefail
17+
18+
ORG="supermodeltools"
19+
20+
WORKFLOW_CONTENT='name: Architecture Docs
21+
22+
on:
23+
push:
24+
branches: [main, master]
25+
workflow_dispatch:
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
build-and-deploy:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- uses: supermodeltools/arch-docs@main
37+
id: docs
38+
with:
39+
supermodel-api-key: ${{ secrets.SUPERMODEL_API_KEY }}
40+
base-url: https://repos.supermodeltools.com
41+
42+
- name: Deploy to central site
43+
env:
44+
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
45+
REPO_NAME: ${{ github.event.repository.name }}
46+
run: |
47+
git config --global user.name "supermodel-bot"
48+
git config --global user.email "bot@supermodeltools.com"
49+
git clone https://x-access-token:${BOT_TOKEN}@github.com/GraphTechnologyDevelopers/graphtechnologydevelopers.github.io.git central-site
50+
rm -rf central-site/site/${REPO_NAME}
51+
mkdir -p central-site/site/${REPO_NAME}
52+
cp -r arch-docs-output/. central-site/site/${REPO_NAME}/
53+
cd central-site
54+
git add site/${REPO_NAME}/
55+
git diff --staged --quiet && echo "No changes" && exit 0
56+
git commit -m "Deploy arch-docs for ${REPO_NAME}"
57+
for i in 1 2 3 4 5; do
58+
git push && break
59+
echo "Push failed, retrying in ${i}0s..."
60+
sleep $((i * 10))
61+
git pull --rebase origin main
62+
done'
63+
64+
# Read repo names from repos.yaml
65+
REPOS=$(grep "^ - name:" repos.yaml | awk '{print $3}')
66+
67+
for REPO_NAME in $REPOS; do
68+
FORK="${ORG}/${REPO_NAME}"
69+
echo "=== Updating ${FORK} ==="
70+
71+
# Set BOT_TOKEN secret if provided
72+
if [ -n "${BOT_TOKEN:-}" ]; then
73+
echo " Setting BOT_TOKEN secret..."
74+
gh secret set BOT_TOKEN --repo "${FORK}" --body "${BOT_TOKEN}"
75+
else
76+
echo " Warning: BOT_TOKEN not set in environment, skipping secret update"
77+
fi
78+
79+
ENCODED=$(echo -n "${WORKFLOW_CONTENT}" | base64)
80+
DEFAULT_BRANCH=$(gh api "repos/${FORK}" --jq '.default_branch' 2>/dev/null || echo "main")
81+
EXISTING_SHA=$(gh api "repos/${FORK}/contents/.github/workflows/arch-docs.yml" --jq '.sha' 2>/dev/null || echo "")
82+
83+
if [ -n "${EXISTING_SHA}" ]; then
84+
gh api --method PUT "repos/${FORK}/contents/.github/workflows/arch-docs.yml" \
85+
-f message="Update arch-docs workflow to deploy to central site" \
86+
-f content="${ENCODED}" \
87+
-f branch="${DEFAULT_BRANCH}" \
88+
-f sha="${EXISTING_SHA}" \
89+
--silent
90+
echo " Updated arch-docs.yml"
91+
else
92+
echo " No arch-docs.yml found in ${FORK}, skipping"
93+
fi
94+
95+
echo ""
96+
done
97+
98+
echo "=== Done! Run workflows manually to trigger initial deploys: ==="
99+
for REPO_NAME in $REPOS; do
100+
echo " gh workflow run arch-docs.yml --repo ${ORG}/${REPO_NAME}"
101+
done

0 commit comments

Comments
 (0)