CI/CD Pipeline

Next.js → VPS Deploy

A production-ready deployment pipeline using GitHub Actions, PM2, and Nginx.

How it works

01

Push to main

Commit and push your changes to the main branch on GitHub.

02

GitHub Actions triggers

The deploy workflow runs: installs deps, builds the app, and copies artifacts to the VPS via SSH.

03

PM2 restarts the app

The remote server reloads the process with zero downtime using PM2 cluster mode.

04

Nginx serves traffic

Nginx reverse-proxies requests from port 80/443 to the Next.js app running on port 3000.

Required GitHub Secrets

Secret nameDescription
VPS_HOSTIP or domain of your VPS
VPS_USERSSH user (e.g. deploy)
VPS_SSH_KEYPrivate SSH key (PEM, no passphrase)
VPS_PORTSSH port (default 22)
APP_DIRAbsolute path to app on server