-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (70 loc) · 2.57 KB
/
deploy.yml
File metadata and controls
87 lines (70 loc) · 2.57 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
name: Deploy Production
on:
push:
branches: [ "main" ]
env:
BINARY_NAME: server
jobs:
build_and_deploy:
name: Build & Deploy
runs-on: ubuntu-latest
environment: SSH_PRIVATE_KEY
steps:
- uses: actions/checkout@v4
# This fixes the "pkg-config" error for the frontend build on the host runner.
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
# FRONTEND BUILD (Leptos)
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown, x86_64-unknown-linux-musl
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install Trunk
uses: jetli/trunk-action@v0.4.0
- name: Build Frontend
working-directory: ./client
env:
API_URL: "https://trycli.com"
WS_URL: "wss://trycli.com"
run: trunk build --release
# BACKEND BUILD (Axum)
- name: Install Cross
run: cargo install cross
- name: Build Backend (Static Binary)
# ⚠️ CHANGE: Run from root to ensure workspace lockfile is respected
# and point to the server binary explicitly.
env:
SQLX_OFFLINE: true # <--- ADD THIS LINE
run: cross build --release --target x86_64-unknown-linux-musl --bin server
# DEPLOYMENT
- name: Prepare Deployment Package
run: |
mkdir deploy_package
# ⚠️ FIX: Path is now 'target/...' not 'server/target/...'
cp target/x86_64-unknown-linux-musl/release/${{ env.BINARY_NAME }} deploy_package/server_bin
# Frontend 'dist' is still inside client/ because trunk ran there
cp -r client/dist deploy_package/dist
- name: Deploy to DigitalOcean
uses: appleboy/scp-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: deploy
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "deploy_package/*"
target: "/home/deploy/app"
strip_components: 1
- name: Restart Application
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: deploy
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
chmod +x /home/deploy/app/server_bin
# Ensure your systemd file points to /home/deploy/app/server_bin
# and Environment="LEPTOS_SITE_ROOT=./dist"
sudo systemctl restart trycli