Manual SSH deployments are technical debt.
We want this:
git push origin main → website auto-updates
The Deployment Flow
graph LR
A[git push to main] --> B[GitHub Actions triggered]
B --> C[SSH into VPS]
C --> D[git pull origin main]
D --> E[Reload Nginx]
E --> F[Site updated]
Step 1 — Prepare Your Website Repo
Your repo should look like:
.
├── index.html
├── assets/
└── ...
Step 2 — Create Deployment User (Recommended)
On your VPS:
adduser deploy
usermod -aG sudo deploy
Give ownership of the website directory:
chown -R deploy:deploy /var/www/rayeen.in
Step 3 — Setup SSH Key for GitHub Actions
On VPS (as the deploy user):
su - deploy
ssh-keygen -t ed25519 -C "github-deploy"
Copy the public key:
cat ~/.ssh/id_ed25519.pub
Add this key to:
GitHub → Repo → Settings → Deploy Keys → Add Key
Enable Allow write access.
Step 4 — Add Private Key to GitHub Secrets
Copy the private key:
cat ~/.ssh/id_ed25519
In GitHub, go to Settings → Secrets → Actions → New Secret and add:
| Secret Name | Value |
|---|---|
SSH_PRIVATE_KEY | Contents of id_ed25519 |
VPS_HOST | Your VPS IP address |
VPS_USER | deploy |
Step 5 — Create GitHub Action
Create .github/workflows/deploy.yml:
name: Deploy Website
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /var/www/rayeen.in
git pull origin main
sudo systemctl reload nginx
Now every push to main triggers an automatic deployment.
What We Achieved
- No manual uploads or SSH-into-server deployments
- Secure SSH-based deployment via ed25519 keys
- Auto reload of Nginx on every push
- Infrastructure defined as a workflow
This is CI/CD ownership.