Most tutorials assume you're deploying to a VPS or cloud provider. But a lot of freelance projects — especially WordPress sites and React SPAs — live on shared hosting like cPanel or NOC.com. Here's how I automated deployments for exactly that setup.
The Problem
Shared hosting doesn't give you Docker or systemd. But almost every shared host provides SSH access. That's all we need.
Step 1 — Generate a Deploy SSH Key
On your local machine:
ssh-keygen -t ed25519 -C "github-deploy" -f ~/.ssh/deploy_key -N ""This creates two files: - `~/.ssh/deploy_key` — private key (goes into GitHub Secrets) - `~/.ssh/deploy_key.pub` — public key (goes on the server)
Step 2 — Authorize the Key on the Server
ssh-copy-id -i ~/.ssh/deploy_key.pub -p 5022 user@yourhost.comTest it:
ssh -p 5022 -i ~/.ssh/deploy_key user@yourhost.com "echo OK"Step 3 — Add Secrets to GitHub
Go to your repo → Settings → Secrets and variables → Actions:
| Secret | Value | |--------|-------| | `SSH_PRIVATE_KEY` | content of `~/.ssh/deploy_key` | | `VITE_EMAILJS_SERVICE_ID` | your EmailJS service ID |
Step 4 — The Workflow File
`.github/workflows/deploy.yml`:
name: Build & Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- name: Build
run: npm run build
env:
VITE_EMAILJS_SERVICE_ID: ${{ secrets.VITE_EMAILJS_SERVICE_ID }}
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -p 5022 yourhost.com >> ~/.ssh/known_hosts
- name: Deploy via rsync
run: |
rsync -avz --delete \
-e "ssh -p 5022 -i ~/.ssh/id_ed25519" \
./dist/ \
user@yourhost.com:~/public_html/Step 5 — React Router Fix (.htaccess)
If you're deploying a React SPA, direct URL access (e.g. `yoursite.com/about`) returns 404 by default. Fix it with a `public/.htaccess` file:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]This gets copied into `dist/` automatically at build time.
Caching Headers (Optional)
Add this to `.htaccess` for better performance:
<FilesMatch "\.(js|css|woff2|png|jpg|svg)$">
Header set Cache-Control "max-age=31536000, public, immutable"
</FilesMatch>Conclusion
This setup gives you production-grade CI/CD on a €5/month shared host. Every push to `main` triggers a build and a live deployment in about 2 minutes. No manual FTP, no SSH-ing in to pull changes — just `git push` and it's done.