-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (79 loc) · 2.88 KB
/
Copy pathdeploy.yml
File metadata and controls
92 lines (79 loc) · 2.88 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
name: Deploy StaticFlow Frontend (Production)
on:
push:
branches:
- master
paths:
- 'crates/frontend/**'
- 'crates/shared/src/**'
- 'crates/shared/Cargo.toml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- '.github/workflows/deploy.yml'
workflow_dispatch: # 允许手动触发
permissions:
contents: write
pages: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install Trunk 0.21.14
run: |
curl -L https://github.com/trunk-rs/trunk/releases/download/v0.21.14/trunk-x86_64-unknown-linux-musl.tar.gz -o trunk.tar.gz
tar -xzf trunk.tar.gz
chmod +x trunk
sudo mv trunk /usr/local/bin/trunk
trunk --version
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: crates/frontend/package-lock.json
- name: Install npm dependencies
working-directory: crates/frontend
run: npm install
- name: Install wasm-opt (from binaryen)
run: |
wget https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-linux.tar.gz
tar -xzf binaryen-version_116-x86_64-linux.tar.gz
mkdir -p ~/.cache/trunk/wasm-opt-version_116/bin
cp binaryen-version_116/bin/wasm-opt ~/.cache/trunk/wasm-opt-version_116/bin/
chmod +x ~/.cache/trunk/wasm-opt-version_116/bin/wasm-opt
~/.cache/trunk/wasm-opt-version_116/bin/wasm-opt --version
- name: Build frontend (production)
working-directory: crates/frontend
run: trunk build --release
env:
STATICFLOW_API_BASE: ${{ vars.STATICFLOW_API_BASE }}
TRUNK_SKIP_VERSION_CHECK: "true"
- name: Copy 404.html to dist root (GitHub Pages SPA routing)
working-directory: crates/frontend
run: cp 404.html dist/404.html
- name: Copy standalone pages to dist
working-directory: crates/frontend
run: |
if [ -d "standalone" ] && [ "$(ls -A standalone 2>/dev/null)" ]; then
cp -r standalone dist/
echo "Copied standalone pages to dist/standalone/"
else
echo "No standalone pages found, skipping"
fi
- name: Deploy to User Pages (acking-you.github.io)
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
external_repository: acking-you/acking-you.github.io
publish_dir: crates/frontend/dist
publish_branch: master
force_orphan: true