-
-
Notifications
You must be signed in to change notification settings - Fork 35
137 lines (119 loc) · 4.48 KB
/
Copy pathdeploy-web-demo.yml
File metadata and controls
137 lines (119 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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/ — Astro now renders specs from docs/wiki/specs/**/*.md
# via the `specs` content collection. Static HTML files in
# web_demo/specs/ remain as LEGACY fallbacks for URLs not yet
# migrated to markdown (gesture-system.html, neural-prediction.html,
# etc.). `cp -n` (no-clobber) ensures Astro-generated files like
# /specs/index.html and /specs/typing/autocorrect-spec/index.html
# take precedence over their legacy counterparts.
if [ -d "web_demo/specs" ]; then
mkdir -p site/dist/specs
cp -rn web_demo/specs/. site/dist/specs/ || true
echo "✅ Merged web_demo/specs into site/dist/specs (no-clobber)"
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