Repository navigation
84 lines (73 loc) · 2.69 KB
/
Copy pathdeploy-examples.yml
File metadata and controls
84 lines (73 loc) · 2.69 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
name: Deploy Examples
on:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: deploy-examples
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: production
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build vanilla example
run: pnpm -C packages/examples/js-vanilla run build
- name: Build react example
run: pnpm -C packages/examples/react run build
- name: Assemble pages
run: |
mkdir -p pages/vanilla pages/react
cp -r packages/examples/js-vanilla/dist/. pages/vanilla/
cp -r packages/examples/react/dist/. pages/react/
cat > pages/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Spatial — Examples</title>
<style>
body { font-family: sans-serif; max-width: 480px; margin: 80px auto; padding: 0 24px; }
h1 { font-size: 1.5rem; margin-bottom: 8px; }
p { color: #555; margin-bottom: 32px; }
a { display: block; padding: 14px 20px; border: 1px solid #e5e7eb;
border-radius: 8px; text-decoration: none; color: #111;
margin-bottom: 12px; }
a:hover { background: #f9fafb; }
a span { display: block; font-size: 0.85rem; color: #888; margin-top: 2px; }
</style>
</head>
<body>
<h1>Spatial</h1>
<p>Interactive 2D editor toolkit — live examples</p>
<a href="vanilla/">
Vanilla JS
<span>@spatial-kit/core + @spatial-kit/svg</span>
</a>
<a href="react/">
React
<span>@spatial-kit/core + @spatial-kit/react</span>
</a>
</body>
</html>
EOF
- name: Deploy to Cloudflare
id: deploy
run: |
OUTPUT=$(pnpm dlx wrangler@4.145.0 deploy --assets=./pages 2>&1)
echo "$OUTPUT"
URL=$(echo "$OUTPUT" | grep -oE 'https://[a-zA-Z0-9._-]+\.workers\.dev' | tail -1)
echo "url=$URL" >> $GITHUB_OUTPUT
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}