mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-28 05:12:26 +00:00
The docs-site leaderboard (docs/javascripts/leaderboard.js) reads the public Supabase anon key from window.OPENJARVIS_SUPABASE_ANON_KEY, but nothing set it, so the published leaderboard always rendered "Leaderboard not configured yet". Add a generated config file (leaderboard-config.js) loaded before leaderboard.js that supplies the global, and inject its value at docs-build time from the existing VITE_SUPABASE_ANON_KEY repo secret. The committed default is empty, so local `mkdocs build` and fork PRs (no secret) degrade gracefully. The anon key is public by design (Supabase RLS protects the data). - docs/javascripts/leaderboard-config.js: empty-default global declaration. - mkdocs.yml: load leaderboard-config.js before leaderboard.js. - docs.yml: write the config from the secret (read via env, JSON-encoded into a JS string literal to avoid injection) before `mkdocs build`. - tests/deployment/test_docs_leaderboard.py: guard the wiring + load order. Verified with a local `mkdocs build`: the generated config ships in site/ and loads before leaderboard.js. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
84 lines
2.3 KiB
YAML
84 lines
2.3 KiB
YAML
name: Deploy Documentation
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "docs/**"
|
|
- "mkdocs.yml"
|
|
- "src/openjarvis/**"
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- "docs/**"
|
|
- "mkdocs.yml"
|
|
- "src/openjarvis/**"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: "pages"
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v8.0.0
|
|
|
|
- name: Install dependencies
|
|
run: uv sync --extra docs
|
|
|
|
# Inject the public Supabase anon key so the savings leaderboard works on
|
|
# the published docs site. Missing/empty (e.g. fork PRs) leaves the
|
|
# leaderboard gracefully disabled. The key is read from env (not inlined)
|
|
# and JSON-encoded into a JS string literal to avoid any injection.
|
|
- name: Inject leaderboard Supabase anon key
|
|
env:
|
|
OPENJARVIS_LEADERBOARD_ANON: ${{ secrets.VITE_SUPABASE_ANON_KEY }}
|
|
run: |
|
|
python3 - <<'PY'
|
|
import json, os, pathlib
|
|
|
|
key = os.environ.get("OPENJARVIS_LEADERBOARD_ANON", "")
|
|
pathlib.Path("docs/javascripts/leaderboard-config.js").write_text(
|
|
"// Generated at docs-build time from the VITE_SUPABASE_ANON_KEY secret.\n"
|
|
"window.OPENJARVIS_SUPABASE_ANON_KEY = " + json.dumps(key) + ";\n",
|
|
encoding="utf-8",
|
|
)
|
|
print("leaderboard anon key:", "set" if key else "empty (leaderboard disabled)")
|
|
PY
|
|
|
|
- name: Build documentation
|
|
run: uv run mkdocs build
|
|
|
|
- name: Upload artifact
|
|
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
|
uses: actions/upload-pages-artifact@v5.0.0
|
|
with:
|
|
path: site/
|
|
|
|
deploy:
|
|
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v5
|