VPS Deploy via GitHub Actions
Workflow file: `.github/workflows/deploy-vps.yml`
What this workflow does
1. Checks out the deploy ref in GitHub Actions.
2. Syncs the checked-out repo to the VPS over SSH.
3. Validates server tools (`node`, `npm`, `pm2`).
4. Installs dependencies.
5. Runs Prisma deploy + frontend build.
6. Restarts PM2 app `chimti`.
7. Checks backend health on `http://127.0.0.1:4000/v1/health`.
What you need to provide
Set these GitHub repository secrets:
- `VPS_HOST`: VPS public IP or domain
- `VPS_SSH_KEY`: private key content for `root` on the VPS
- `VPS_PORT` (optional): SSH port, default `22`
The workflow connects as `root`, uploads the current repo snapshot, and then runs deploy commands as the server deploy user.
App directory is static in workflow:
- `/home/otlu-chimti/htdocs/chimti.otlu.io`
Helper command (run from repo root) to set secrets interactively:
./scripts/setup-gh-vps-secrets.sh
VPS one-time setup required
1. Create the target directory once on server:
mkdir -p /home/otlu-chimti/htdocs/chimti.otlu.io
2. Install runtime dependencies:
sudo apt update
sudo apt install -y git curl
# install node + npm + pm2 as per your server standard
3. Create backend env file:
cp /home/otlu-chimti/htdocs/chimti.otlu.io/backend/.env.example /home/otlu-chimti/htdocs/chimti.otlu.io/backend/.env
Fill production values in `backend/.env` (`DATABASE_URL`, `AUTH_TOKEN_SECRET`, `CORS_ORIGIN`, API keys, etc).
4. Ensure PM2 is installed globally:
npm i -g pm2
Trigger deploy
- Auto: push to `main`
- Manual: GitHub Actions -> `Deploy VPS` -> `Run workflow` (optional custom `ref`)
First run note
On first successful run, workflow starts PM2 app as:
pm2 start npm --name chimti -- run backend:start
After that, next deploys will restart the same app.