chore(sync): update registry and README (#48) #135
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: pages | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'registry.json' | |
| - 'README.md' | |
| - 'schemas/**' | |
| - 'docs/**' | |
| - 'site/**' | |
| - '.github/workflows/pages.yml' | |
| schedule: | |
| # Daily safety-net rebuild. sync.yml opens a bot PR each morning; | |
| # GITHUB_TOKEN-merged PRs don't trigger downstream workflows, so this | |
| # cron guarantees the site catches up within 24h of any registry | |
| # change even when the post-merge push doesn't fire pages. | |
| - cron: '30 3 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| # pin: v6.0.0 -- actions/checkout | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 | |
| # pin: v6.0.0 -- actions/setup-node | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Stage site | |
| run: | | |
| set -euo pipefail | |
| mkdir -p _site | |
| # Copy data + schemas + docs | |
| cp registry.json _site/ | |
| cp -r schemas _site/ | |
| cp -r docs _site/ | |
| cp README.md _site/README.md | |
| # Copy static site assets (index.html, app.js, viewer.js, styles.css, about.html) | |
| cp -r site/. _site/ | |
| # Generate sitemap.xml from registry.json. The renderer always | |
| # writes the file (no content-compare short-circuit) — `_site/` is | |
| # a fresh staging dir per run, so write avoidance buys nothing. The | |
| # output is content-deterministic for a given (registry, date) | |
| # pair: identical inputs produce identical XML, which is what | |
| # actually matters for crawler ETag caching downstream. | |
| # robots.txt and /.well-known/security.txt are static and were | |
| # copied with the rest of site/. | |
| node scripts/render-sitemap.mjs --registry registry.json --out _site/sitemap.xml | |
| # Pre-render README -> _site/about.html, splicing the rendered body | |
| # between the BEGIN/END markers in site/about.html. | |
| npx -y marked@14 README.md > _readme.html | |
| node -e ' | |
| const fs = require("fs"); | |
| const tpl = fs.readFileSync("site/about.html", "utf8"); | |
| const body = fs.readFileSync("_readme.html", "utf8"); | |
| const begin = "<!-- BEGIN README -->"; | |
| const end = "<!-- END README -->"; | |
| const i = tpl.indexOf(begin); | |
| const j = tpl.indexOf(end); | |
| if (i === -1 || j === -1) { | |
| throw new Error("about.html missing BEGIN/END README markers"); | |
| } | |
| const out = tpl.slice(0, i + begin.length) + "\n" + body + "\n" + tpl.slice(j); | |
| fs.writeFileSync("_site/about.html", out); | |
| ' | |
| rm _readme.html | |
| - name: Apply Cloudflare beacon token | |
| if: env.CF_BEACON_TOKEN != '' | |
| env: | |
| CF_BEACON_TOKEN: ${{ secrets.CF_BEACON_TOKEN }} | |
| run: | | |
| for f in _site/index.html _site/about.html _site/add.html; do | |
| [ -f "$f" ] && sed -i 's/PLACEHOLDER_TOKEN/'"$CF_BEACON_TOKEN"'/g' "$f" | |
| done | |
| # pin: v5.0.0 -- actions/upload-pages-artifact | |
| - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 | |
| with: | |
| path: _site | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deploy.outputs.page_url }} | |
| steps: | |
| # pin: v5.0.0 -- actions/deploy-pages | |
| - id: deploy | |
| uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 |