Skip to content

fix(demo): restore working ONNX swipe demo with Android encoder/decoder #73

fix(demo): restore working ONNX swipe demo with Android encoder/decoder

fix(demo): restore working ONNX swipe demo with Android encoder/decoder #73

name: Deploy cleverkeys.app
on:
push:
branches: [main]
paths:
- 'site/**'
- 'web_demo/**'
- 'docs/wiki/**'
- 'README.md'
- '.github/workflows/deploy-web-demo.yml'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: 'pages'
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: site
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Ensure LFS files
run: git lfs install && git lfs pull
working-directory: .
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install site dependencies
run: bun install --frozen-lockfile
- name: Build Astro site
run: bun run build
env:
ASTRO_TELEMETRY_DISABLED: '1'
- name: Merge legacy demo & specs into dist
working-directory: .
run: |
set -euo pipefail
# /demo/ — ONNX-powered swipe demo. The HTML lives at
# web_demo/demo/index.html and hits the same encoder/decoder
# pair (swipe_encoder_android.onnx / swipe_decoder_android.onnx)
# that the Android build ships inside the APK.
if [ -d "web_demo/demo" ]; then
mkdir -p site/dist/demo
cp -r web_demo/demo/. site/dist/demo/
echo "✅ Copied web_demo/demo → site/dist/demo"
fi
# Supporting assets referenced by the demo (ONNX, tokenizer, vocab, JS, fonts)
for pattern in '*.onnx' '*.js' '*.json' '*.css' '*.ttf' '*.woff' '*.woff2' '*.png' '*.jpg' '*.svg'; do
cp -n web_demo/$pattern site/dist/demo/ 2>/dev/null || true
done
# /specs/ — technical specifications (static HTML snapshot)
if [ -d "web_demo/specs" ]; then
mkdir -p site/dist/specs
cp -r web_demo/specs/. site/dist/specs/
echo "✅ Copied web_demo/specs → site/dist/specs"
fi
# Backwards-compatible redirects for any old .html wiki URLs that
# might be cached or linked externally.
# The new wiki routes omit .html and lowercase path segments.
if [ -d "web_demo/wiki" ]; then
find web_demo/wiki -type f -name "*.html" | while read f; do
rel="${f#web_demo/wiki/}"
# /wiki/foo/bar.html -> /wiki/foo/bar/
slug="${rel%.html}"
slug_lower="$(echo "$slug" | tr '[:upper:]' '[:lower:]')"
target="/wiki/${slug_lower}/"
# Skip if a file with this exact path already exists in dist
if [ -f "site/dist/wiki/${rel}" ]; then
continue
fi
mkdir -p "site/dist/wiki/$(dirname "$rel")"
cat > "site/dist/wiki/${rel}" <<EOF
<!doctype html><meta charset="utf-8">
<title>Redirecting…</title>
<link rel="canonical" href="${target}">
<meta http-equiv="refresh" content="0;url=${target}">
<p>Redirecting to <a href="${target}">${target}</a>.</p>
EOF
done
fi
# CNAME lives in site/public/ and is copied automatically by Astro,
# but we reassert it here so the deploy artifact always has it.
echo "cleverkeys.app" > site/dist/CNAME
echo "---"
echo "📊 Deploy tree:"
find site/dist -maxdepth 2 -type d | sort
echo "---"
echo "📦 Total size: $(du -sh site/dist | cut -f1)"
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site/dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4