Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/build-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ name: Build Index
on:
push:
branches: [main]
paths: [repos.yaml, generate-index.go, go.mod, go.sum, .github/workflows/build-index.yml]
paths:
- repos.yaml
- generate-index.go
- go.mod
- go.sum
- .github/workflows/build-index.yml
- site/**
workflow_dispatch:

permissions:
Expand Down
11 changes: 8 additions & 3 deletions generate-index.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ func main() {
func generateSitemap(cfg Config) error {
var b strings.Builder
b.WriteString(`<?xml version="1.0" encoding="UTF-8"?>` + "\n")
b.WriteString(`<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">` + "\n")
b.WriteString(`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">` + "\n")
b.WriteString(fmt.Sprintf(" <url>\n <loc>%s/</loc>\n <priority>1.0</priority>\n </url>\n", baseURL))
for _, cat := range cfg.Categories {
for _, repo := range cat.Repos {
b.WriteString(fmt.Sprintf(" <sitemap>\n <loc>%s/%s/sitemap.xml</loc>\n </sitemap>\n", baseURL, url.PathEscape(repo.Name)))
b.WriteString(fmt.Sprintf(" <url>\n <loc>%s/%s/</loc>\n <priority>0.8</priority>\n </url>\n", baseURL, url.PathEscape(repo.Name)))
}
}
b.WriteString("</sitemapindex>\n")
b.WriteString("</urlset>\n")
return os.WriteFile("site/sitemap.xml", []byte(b.String()), 0644)
}

Expand Down Expand Up @@ -119,6 +120,10 @@ func generateRepoPages(cfg Config) error {
for _, cat := range cfg.Categories {
for _, repo := range cat.Repos {
dir := fmt.Sprintf("site/%s", url.PathEscape(repo.Name))
// Skip if arch-docs have already been deployed to this directory
if _, err := os.Stat(fmt.Sprintf("%s/index.html", dir)); err == nil {
continue
}
if err := os.MkdirAll(dir, 0755); err != nil {
return fmt.Errorf("creating dir %s: %w", dir, err)
}
Expand Down
43 changes: 24 additions & 19 deletions setup-community-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,41 @@ on:
workflow_dispatch:

permissions:
contents: write
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true
contents: read

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- uses: actions/checkout@v4

- uses: supermodeltools/arch-docs@main
id: docs
with:
supermodel-api-key: ${{ secrets.SUPERMODEL_API_KEY }}

- uses: actions/configure-pages@v5

- uses: actions/upload-pages-artifact@v3
with:
path: ./arch-docs-output

- uses: actions/deploy-pages@v4
id: deploy'
base-url: https://repos.supermodeltools.com

- name: Deploy to central site
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
REPO_NAME: ${{ github.event.repository.name }}
run: |
git config --global user.name "supermodel-bot"
git config --global user.email "bot@supermodeltools.com"
git clone https://x-access-token:${BOT_TOKEN}@github.com/GraphTechnologyDevelopers/graphtechnologydevelopers.github.io.git central-site
rm -rf central-site/site/${REPO_NAME}
mkdir -p central-site/site/${REPO_NAME}
cp -r arch-docs-output/. central-site/site/${REPO_NAME}/
cd central-site
git add site/${REPO_NAME}/
git diff --staged --quiet && echo "No changes" && exit 0
git commit -m "Deploy arch-docs for ${REPO_NAME}"
for i in 1 2 3 4 5; do
git push && break
echo "Push failed, retrying in ${i}0s..."
sleep $((i * 10))
git pull --rebase origin main
done'

for UPSTREAM in "${REPOS[@]}"; do
REPO_NAME="${UPSTREAM##*/}"
Expand Down
101 changes: 101 additions & 0 deletions update-arch-docs-workflows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env bash
# update-arch-docs-workflows.sh
#
# Updates arch-docs.yml in all repos listed in repos.yaml to push output
# to the central GraphTechnologyDevelopers/graphtechnologydevelopers.github.io
# site instead of deploying to individual GitHub Pages.
#
# Prerequisites:
# - gh CLI authenticated with supermodeltools org access
# - BOT_TOKEN secret must be set on each repo (PAT with write access to
# GraphTechnologyDevelopers/graphtechnologydevelopers.github.io)
#
# Usage:
# BOT_TOKEN=ghp_... ./update-arch-docs-workflows.sh

set -euo pipefail

ORG="supermodeltools"

WORKFLOW_CONTENT='name: Architecture Docs

on:
push:
branches: [main, master]
workflow_dispatch:

permissions:
contents: read

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: supermodeltools/arch-docs@main
id: docs
with:
supermodel-api-key: ${{ secrets.SUPERMODEL_API_KEY }}
base-url: https://repos.supermodeltools.com

- name: Deploy to central site
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
REPO_NAME: ${{ github.event.repository.name }}
run: |
git config --global user.name "supermodel-bot"
git config --global user.email "bot@supermodeltools.com"
git clone https://x-access-token:${BOT_TOKEN}@github.com/GraphTechnologyDevelopers/graphtechnologydevelopers.github.io.git central-site
rm -rf central-site/site/${REPO_NAME}
mkdir -p central-site/site/${REPO_NAME}
cp -r arch-docs-output/. central-site/site/${REPO_NAME}/
cd central-site
git add site/${REPO_NAME}/
git diff --staged --quiet && echo "No changes" && exit 0
git commit -m "Deploy arch-docs for ${REPO_NAME}"
for i in 1 2 3 4 5; do
git push && break
echo "Push failed, retrying in ${i}0s..."
sleep $((i * 10))
git pull --rebase origin main
done'

# Read repo names from repos.yaml
REPOS=$(grep "^ - name:" repos.yaml | awk '{print $3}')

for REPO_NAME in $REPOS; do
FORK="${ORG}/${REPO_NAME}"
echo "=== Updating ${FORK} ==="

# Set BOT_TOKEN secret if provided
if [ -n "${BOT_TOKEN:-}" ]; then
echo " Setting BOT_TOKEN secret..."
gh secret set BOT_TOKEN --repo "${FORK}" --body "${BOT_TOKEN}"
else
echo " Warning: BOT_TOKEN not set in environment, skipping secret update"
fi

ENCODED=$(echo -n "${WORKFLOW_CONTENT}" | base64)
DEFAULT_BRANCH=$(gh api "repos/${FORK}" --jq '.default_branch' 2>/dev/null || echo "main")
EXISTING_SHA=$(gh api "repos/${FORK}/contents/.github/workflows/arch-docs.yml" --jq '.sha' 2>/dev/null || echo "")

if [ -n "${EXISTING_SHA}" ]; then
gh api --method PUT "repos/${FORK}/contents/.github/workflows/arch-docs.yml" \
-f message="Update arch-docs workflow to deploy to central site" \
-f content="${ENCODED}" \
-f branch="${DEFAULT_BRANCH}" \
-f sha="${EXISTING_SHA}" \
--silent
echo " Updated arch-docs.yml"
else
echo " No arch-docs.yml found in ${FORK}, skipping"
fi

echo ""
done

echo "=== Done! Run workflows manually to trigger initial deploys: ==="
for REPO_NAME in $REPOS; do
echo " gh workflow run arch-docs.yml --repo ${ORG}/${REPO_NAME}"
done