1- name : Deploy CleverKeys Web Demo
1+ name : Deploy cleverkeys.app
22
33on :
44 push :
5- branches : [ main ]
6- paths : [ 'web_demo/**', 'README.md', 'docs/wiki/**' ]
5+ branches : [main]
6+ paths :
7+ - ' site/**'
8+ - ' web_demo/**'
9+ - ' docs/wiki/**'
10+ - ' README.md'
11+ - ' .github/workflows/deploy-web-demo.yml'
712 workflow_dispatch :
813
914permissions :
@@ -12,12 +17,15 @@ permissions:
1217 id-token : write
1318
1419concurrency :
15- group : " pages"
20+ group : ' pages'
1621 cancel-in-progress : true
1722
1823jobs :
1924 build :
2025 runs-on : ubuntu-latest
26+ defaults :
27+ run :
28+ working-directory : site
2129 steps :
2230 - name : Checkout
2331 uses : actions/checkout@v4
@@ -26,81 +34,90 @@ jobs:
2634
2735 - name : Ensure LFS files
2836 run : git lfs install && git lfs pull
37+ working-directory : .
2938
30- - name : Prepare CleverKeys website and demo
39+ - name : Setup Bun
40+ uses : oven-sh/setup-bun@v2
41+ with :
42+ bun-version : latest
43+
44+ - name : Install site dependencies
45+ run : bun install --frozen-lockfile
46+
47+ - name : Build Astro site
48+ run : bun run build
49+ env :
50+ ASTRO_TELEMETRY_DISABLED : ' 1'
51+
52+ - name : Merge legacy demo & specs into dist
53+ working-directory : .
3154 run : |
32- mkdir -p deploy/demo
33- mkdir -p deploy/specs
34-
35- if [ -d "web_demo" ]; then
36- echo "📁 Setting up CleverKeys website..."
37-
38- # Copy new homepage
39- if [ -f "web_demo/index.html" ]; then
40- cp web_demo/index.html deploy/
41- echo "✅ Homepage ready"
42- fi
43-
44- # Copy demo page (use demo/index.html if exists, otherwise under construction)
45- echo "📁 Setting up demo in /demo/..."
46- if [ -f "web_demo/demo/index.html" ]; then
47- cp web_demo/demo/index.html deploy/demo/index.html
48- echo "✅ Demo page ready (under construction)"
49- elif [ -f "web_demo/swipe-onnx.html" ]; then
50- cp web_demo/swipe-onnx.html deploy/demo/index.html
51- echo "✅ Demo page ready (neural swipe)"
52- fi
53-
54- # Copy specs documentation
55- echo "📁 Setting up specs documentation in /specs/..."
56- if [ -d "web_demo/specs" ]; then
57- cp -r web_demo/specs/* deploy/specs/
58- echo "✅ Specs documentation ready"
59- fi
60-
61- # Copy wiki user guide
62- echo "📁 Setting up wiki user guide in /wiki/..."
63- if [ -d "web_demo/wiki" ]; then
64- mkdir -p deploy/wiki
65- cp -r web_demo/wiki/* deploy/wiki/
66- echo "✅ Wiki user guide ready (includes search-index.json)"
67- fi
68-
69- # Copy demo supporting files (for when demo is restored)
70- echo "📁 Copying demo assets..."
71- cp web_demo/*.onnx deploy/demo/ 2>/dev/null || echo "ℹ️ No ONNX models"
72- cp web_demo/*.js deploy/demo/ 2>/dev/null || echo "ℹ️ No JS files"
73- cp web_demo/*.json deploy/demo/ 2>/dev/null || echo "ℹ️ No JSON config files"
74- cp web_demo/*.css deploy/demo/ 2>/dev/null || echo "ℹ️ No CSS files"
75-
76- # Copy any font files
77- cp web_demo/*.ttf deploy/demo/ 2>/dev/null || echo "ℹ️ No TTF fonts"
78- cp web_demo/*.woff deploy/demo/ 2>/dev/null || echo "ℹ️ No WOFF fonts"
79- cp web_demo/*.woff2 deploy/demo/ 2>/dev/null || echo "ℹ️ No WOFF2 fonts"
80-
81- # Copy any image files
82- cp web_demo/*.png deploy/demo/ 2>/dev/null || echo "ℹ️ No PNG images"
83- cp web_demo/*.jpg deploy/demo/ 2>/dev/null || echo "ℹ️ No JPG images"
84- cp web_demo/*.svg deploy/demo/ 2>/dev/null || echo "ℹ️ No SVG images"
55+ set -euo pipefail
56+
57+ # /demo/ — ONNX-powered swipe demo (self-contained legacy HTML)
58+ if [ -d "web_demo/demo" ]; then
59+ mkdir -p site/dist/demo
60+ cp -r web_demo/demo/. site/dist/demo/
61+ echo "✅ Copied web_demo/demo → site/dist/demo"
62+ elif [ -f "web_demo/swipe-onnx.html" ]; then
63+ mkdir -p site/dist/demo
64+ cp web_demo/swipe-onnx.html site/dist/demo/index.html
65+ fi
66+
67+ # Supporting assets referenced by the demo (ONNX, tokenizer, vocab, JS, fonts)
68+ for pattern in '*.onnx' '*.js' '*.json' '*.css' '*.ttf' '*.woff' '*.woff2' '*.png' '*.jpg' '*.svg'; do
69+ cp -n web_demo/$pattern site/dist/demo/ 2>/dev/null || true
70+ done
71+
72+ # /specs/ — technical specifications (static HTML snapshot)
73+ if [ -d "web_demo/specs" ]; then
74+ mkdir -p site/dist/specs
75+ cp -r web_demo/specs/. site/dist/specs/
76+ echo "✅ Copied web_demo/specs → site/dist/specs"
8577 fi
8678
87- echo ""
88- echo "✅ Website structure prepared:"
89- echo " / - Homepage"
90- echo " /demo/ - Demo (under construction)"
91- echo " /specs/ - Technical specifications"
92- echo " /wiki/ - User guide wiki (with search-index.json)"
93- echo ""
94- echo "📊 Deployed files:"
95- ls -laR deploy/
79+ # Backwards-compatible redirects for any old .html wiki URLs that
80+ # might be cached or linked externally.
81+ # The new wiki routes omit .html and lowercase path segments.
82+ if [ -d "web_demo/wiki" ]; then
83+ find web_demo/wiki -type f -name "*.html" | while read f; do
84+ rel="${f#web_demo/wiki/}"
85+ # /wiki/foo/bar.html -> /wiki/foo/bar/
86+ slug="${rel%.html}"
87+ slug_lower="$(echo "$slug" | tr '[:upper:]' '[:lower:]')"
88+ target="/wiki/${slug_lower}/"
89+ # Skip if a file with this exact path already exists in dist
90+ if [ -f "site/dist/wiki/${rel}" ]; then
91+ continue
92+ fi
93+ mkdir -p "site/dist/wiki/$(dirname "$rel")"
94+ cat > "site/dist/wiki/${rel}" <<EOF
95+ <!doctype html><meta charset="utf-8">
96+ <title>Redirecting…</title>
97+ <link rel="canonical" href="${target}">
98+ <meta http-equiv="refresh" content="0;url=${target}">
99+ <p>Redirecting to <a href="${target}">${target}</a>.</p>
100+ EOF
101+ done
102+ fi
103+
104+ # CNAME lives in site/public/ and is copied automatically by Astro,
105+ # but we reassert it here so the deploy artifact always has it.
106+ echo "cleverkeys.app" > site/dist/CNAME
107+
108+ echo "---"
109+ echo "📊 Deploy tree:"
110+ find site/dist -maxdepth 2 -type d | sort
111+ echo "---"
112+ echo "📦 Total size: $(du -sh site/dist | cut -f1)"
96113
97114 - name : Configure Pages
98115 uses : actions/configure-pages@v5
99116
100117 - name : Upload Pages artifact
101118 uses : actions/upload-pages-artifact@v3
102119 with :
103- path : ./deploy
120+ path : ./site/dist
104121
105122 deploy :
106123 environment :
@@ -111,4 +128,4 @@ jobs:
111128 steps :
112129 - name : Deploy to GitHub Pages
113130 id : deployment
114- uses : actions/deploy-pages@v4
131+ uses : actions/deploy-pages@v4
0 commit comments