Skip to content

refactor: remove redundant landing page copy and adjust hero section … #105

refactor: remove redundant landing page copy and adjust hero section …

refactor: remove redundant landing page copy and adjust hero section … #105

Workflow file for this run

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
uses: taiki-e/install-action@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 Azure VM
uses: appleboy/scp-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "deploy_package/*"
target: "/home/trycliuser/deploy_tmp"
strip_components: 1
- name: Restart Application
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
# 1. Update Backend Binary
mkdir -p /home/trycliuser/trycli/target/release
cp /home/trycliuser/deploy_tmp/server_bin /home/trycliuser/trycli/target/release/server
chmod +x /home/trycliuser/trycli/target/release/server
# 2. Update Frontend Files
mkdir -p /home/trycliuser/trycli/client/dist
rm -rf /home/trycliuser/trycli/client/dist/*
cp -r /home/trycliuser/deploy_tmp/dist/* /home/trycliuser/trycli/client/dist/
# 3. Inject Environment Variables from GitHub Secrets
cat << EOF > /home/trycliuser/trycli/server/.env
DATABASE_URL=${{ secrets.DATABASE_URL }}
GITHUB_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}
GITHUB_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}
API_URL=https://trycli.com
FRONTEND_URL=https://trycli.com
EOF
chmod 600 /home/trycliuser/trycli/server/.env
# 4. Restart Backend Service
sudo systemctl restart trycli