Skip to content

docs(README.md): refresh deployment URLs and infra wording in README #171

docs(README.md): refresh deployment URLs and infra wording in README

docs(README.md): refresh deployment URLs and infra wording in README #171

Workflow file for this run

# E2E must pass before deploy runs.
name: Deploy to VPS
on:
push:
branches:
- main
workflow_dispatch:
jobs:
e2e:
name: e2e (test)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Install Cypress system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgbm1 libgtk-3-0 libnotify-dev libnss3 libxss1 libxtst6 xauth xvfb
sudo apt-get install -y libasound2 || sudo apt-get install -y libasound2t64
- name: Run E2E
run: bun run e2e
deploy:
needs: e2e
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to VPS via SSH
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
script: |
set -e
set -o pipefail
APP_DIR="${VPS_APP_DIR:-$HOME/metaverse}"
cd "$APP_DIR"
# ---------- Load shell + PATH ----------
[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc" || true
export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
export PATH="$BUN_INSTALL/bin:/usr/local/go/bin:$PATH"
# ---------- Prerequisites (bootstrapped on VPS; no sudo in CI) ----------
for cmd in git bun node npm pm2 go; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Missing required command: $cmd"
echo "Install it on the VPS before running deploy."
exit 1
fi
done
echo "Node: $(node --version)"
echo "npm: $(npm --version)"
echo "Bun: $(bun --version)"
echo "PM2: $(pm2 --version)"
echo "Go: $(go version)"
# ---------- Git Pull ----------
git fetch origin
git checkout main
git reset --hard origin/main
git pull origin main
# ---------- Env ----------
if [ ! -f "packages/config/.env" ]; then
echo "packages/config/.env not found"
exit 1
fi
# ---------- Stop PM2 (fix for ETXTBSY during mediasoup rebuild) ----------
echo "Stopping PM2 to release file locks..."
pm2 stop metaverse-client metaverse-server metaverse-world || true
# ---------- Install deps ----------
bun install
# ---------- Rebuild Mediasoup ----------
echo "Rebuilding Mediasoup..."
npm rebuild mediasoup
# ---------- Prisma ----------
cd packages/store
bunx prisma migrate deploy || true
bunx prisma generate || true
cd "$APP_DIR"
# ---------- Build Client ----------
cd apps/client
bun run build
cd "$APP_DIR"
# ---------- Build World WS ----------
cd apps/world
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o world-server
cd "$APP_DIR"
# ---------- Server ----------
echo "Server is Bun-native, no build step."
# ---------- PM2 reload (client, server, world — no sudo) ----------
pm2 reload ecosystem.config.cjs || pm2 start ecosystem.config.cjs
pm2 save