This repository demonstrates a fully automated CI/CD workflow that deploys a Next.js application from GitHub directly to cPanel using SSH — fast, secure, and maintenance-free.
- 🔄 Automatic Deployment — Every push to the
mainbranch triggers a build and deployment to your cPanel server. - 🔐 Secure SSH Connection — Uses GitHub Secrets to safely manage credentials.
- ⚡ Optimized Deployment — Bundled as
.tar.gzfor faster file transfers. - 🧱 Complete Next.js Support — Includes
.next,public, and dependency management. - 🧩 Modular Configuration — Uses environment secrets for flexible and reusable setup.
GitHub Actions workflow:
📂 .github/workflows/deploy.yml
- Checkout repository
- Setup Node.js environment
- Install dependencies with
npm ci - Build Next.js production app (
npm run build) - Compress build output into
build-output.tar.gz - Upload to cPanel server via
appleboy/scp-action - Extract and deploy automatically inside your server environment
Add these in your GitHub repository → Settings → Secrets → Actions:
| Key | Description |
|---|---|
SSH_HOST |
Server hostname or IP |
SSH_USER |
SSH username |
SSH_PRIVATE_KEY |
Private SSH key |
SSH_PASSPHRASE |
Optional key passphrase |
DEPLOY_DIR |
Target deployment path |
NODE_MODULES_DIR |
Path to node_modules |
NODE_ENV_PATH |
Path to virtualenv activation |
- 🚀 Starting deployment inside Node.js environment...
- 🔧 Activating environment...
- 📦 Extracting build-output.tar.gz...
- ♻️ Restarting Node.js app...
- ✅ Deployment complete!
- No credentials or private paths are hardcoded — everything is stored securely in GitHub Secrets.
- SSH key-based authentication only (no passwords).
- Each deployment runs in a clean, isolated environment.
This setup offers a production-grade CI/CD pipeline that:
- Works natively with GitHub → cPanel without external runners
- Avoids manual FTP uploads or rebuilds
- Is fully version-controlled and reproducible
Sumberweb DevOps
Simplifying modern web deployment pipelines for cPanel and Node.js environments.
MIT License © 2025 — You’re free to use, modify, and adapt this workflow.