|
| 1 | +# GitHub Pages live demo. |
| 2 | +# |
| 3 | +# Builds the public demo at https://xavi-999.github.io/browsergnome/ : |
| 4 | +# - perf-map.html — a REAL static scan of excalidraw at a pinned SHA (the same commit |
| 5 | +# recorded in references/perf-map.md's calibration note — 527 modules, 16 hotspots). |
| 6 | +# - lcp-map.html — a REAL LCP attribution from the shipped trace fixture |
| 7 | +# (skills/browsergnome/assets/trace.render-blocking-sample.json.gz, a real nextjs.org capture). |
| 8 | +# - report.html — the live run report rendered from the bundled sample run-state |
| 9 | +# (skills/browsergnome/assets/run-state.sample.json). |
| 10 | +# - index.html — landing page (docs/pages/index.html) with real substituted stats. |
| 11 | +# |
| 12 | +# No generated HTML is committed to master — everything is built here and deployed as a |
| 13 | +# Pages artifact. |
| 14 | +# |
| 15 | +# Runs on every push to master, plus manual dispatch. On a free-tier private repo the deploy |
| 16 | +# step will fail (GitHub Pages requires a public repo, or a paid plan) — that's expected until |
| 17 | +# the repo goes public and Pages is enabled once in Settings > Pages. No other change needed |
| 18 | +# here after that; this workflow is otherwise ready to go. |
| 19 | + |
| 20 | +name: Pages |
| 21 | + |
| 22 | +on: |
| 23 | + push: |
| 24 | + branches: [master] |
| 25 | + workflow_dispatch: |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + pages: write |
| 30 | + id-token: write |
| 31 | + |
| 32 | +concurrency: |
| 33 | + group: pages |
| 34 | + cancel-in-progress: true |
| 35 | + |
| 36 | +env: |
| 37 | + # excalidraw main, resolved 2026-08-08 — the calibration commit in references/perf-map.md. |
| 38 | + # Bump deliberately; re-verify hotspot count against the calibration note if you do. |
| 39 | + EXCALIDRAW_SHA: 4872083c044491b6d5c96ae134a75464f96d6831 |
| 40 | + |
| 41 | +jobs: |
| 42 | + build: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Set up Node.js 20 |
| 49 | + uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: 20 |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + run: npm ci |
| 55 | + |
| 56 | + - name: Fetch excalidraw at pinned SHA |
| 57 | + run: | |
| 58 | + git init excalidraw |
| 59 | + git -C excalidraw remote add origin https://github.com/excalidraw/excalidraw |
| 60 | + git -C excalidraw fetch --depth 1 origin "$EXCALIDRAW_SHA" |
| 61 | + git -C excalidraw checkout FETCH_HEAD |
| 62 | +
|
| 63 | + # Alias resolution is make-or-break for fan-in/centrality (13 @excalidraw/* aliases). |
| 64 | + # If the scan prints "aliases (none found)" the graph is meaningless — fail loudly. |
| 65 | + - name: Scan excalidraw (perf_scan) |
| 66 | + run: | |
| 67 | + set -o pipefail |
| 68 | + node skills/browsergnome/scripts/perf_scan.mjs excalidraw --out /tmp/graph.json | tee /tmp/scan.log |
| 69 | + if grep -qE 'aliases +\(none found\)' /tmp/scan.log; then |
| 70 | + echo "::error::perf_scan resolved no import aliases on excalidraw — graph would be meaninglessly sparse" |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | +
|
| 74 | + - name: Build perf map |
| 75 | + run: | |
| 76 | + mkdir -p _site |
| 77 | + node skills/browsergnome/scripts/build_perf_map.mjs /tmp/graph.json --out _site/perf-map.html |
| 78 | +
|
| 79 | + - name: Build LCP attribution map (shipped fixture) |
| 80 | + run: | |
| 81 | + node skills/browsergnome/scripts/lcp_attribution.mjs skills/browsergnome/assets/trace.render-blocking-sample.json.gz > /tmp/attribution.json |
| 82 | + node skills/browsergnome/scripts/build_lcp_map.mjs /tmp/attribution.json --out _site/lcp-map.html |
| 83 | +
|
| 84 | + - name: Build run report (sample run-state) |
| 85 | + run: node skills/browsergnome/scripts/build_run_report.mjs skills/browsergnome/assets/run-state.sample.json --out _site/report.html |
| 86 | + |
| 87 | + - name: Assemble landing page |
| 88 | + run: | |
| 89 | + cp docs/pages/index.html _site/ |
| 90 | + cp docs/logo-badge.svg _site/ |
| 91 | + # Pull the hero numbers from the real scan and the real trace — the page never |
| 92 | + # claims a figure the build didn't measure. |
| 93 | + node -e " |
| 94 | + const g = JSON.parse(require('fs').readFileSync('/tmp/graph.json', 'utf8')); |
| 95 | + const attr = JSON.parse(require('fs').readFileSync('/tmp/attribution.json', 'utf8')); |
| 96 | + const fmt = (n) => n.toLocaleString('en-US'); |
| 97 | + const out = { |
| 98 | + MODULES: fmt(g.nodes.length), |
| 99 | + HOTSPOTS: fmt(g.nodes.filter((n) => n.isHotspot).length), |
| 100 | + FINDINGS: fmt(g.nodes.reduce((s, n) => s + (n.findings?.length || 0), 0)), |
| 101 | + LCP_MS: attr.lcpMs != null ? Math.round(attr.lcpMs) : '?', |
| 102 | + }; |
| 103 | + require('fs').writeFileSync('/tmp/stats.env', Object.entries(out).map(([k, v]) => k + '=' + v).join('\n')); |
| 104 | + " |
| 105 | + . /tmp/stats.env |
| 106 | + sed -i \ |
| 107 | + -e "s/__EXCALIDRAW_SHA__/${EXCALIDRAW_SHA:0:8}/g" \ |
| 108 | + -e "s/__BUILD_DATE__/$(date -u +%Y-%m-%d)/g" \ |
| 109 | + -e "s/__STAT_MODULES__/${MODULES}/g" \ |
| 110 | + -e "s/__STAT_HOTSPOTS__/${HOTSPOTS}/g" \ |
| 111 | + -e "s/__STAT_FINDINGS__/${FINDINGS}/g" \ |
| 112 | + -e "s/__LCP_MS__/${LCP_MS}/g" \ |
| 113 | + _site/index.html |
| 114 | + # nothing un-templated left behind |
| 115 | + if grep -q '__' _site/index.html; then |
| 116 | + echo "::error::unsubstituted placeholder left in index.html" && exit 1 |
| 117 | + fi |
| 118 | +
|
| 119 | + - name: Upload Pages artifact |
| 120 | + uses: actions/upload-pages-artifact@v3 |
| 121 | + with: |
| 122 | + path: _site |
| 123 | + |
| 124 | + deploy: |
| 125 | + needs: build |
| 126 | + runs-on: ubuntu-latest |
| 127 | + environment: |
| 128 | + name: github-pages |
| 129 | + url: ${{ steps.deployment.outputs.page_url }} |
| 130 | + steps: |
| 131 | + - name: Deploy to GitHub Pages |
| 132 | + id: deployment |
| 133 | + uses: actions/deploy-pages@v4 |
0 commit comments