Manual deploys are slow and easy to get wrong: a forgotten migration, a missed file, a server left half-updated. With GitHub Actions, every push to your main branch can be tested and deployed the same way, with a log of exactly what happened. This guide uses plain SSH and a small deploy script, which works for almost any stack and keeps you in control.
How It Fits Together
push to main ─▶ GitHub Actions runner
1. checkout, install, test
2. build release (archive or image)
3. scp release ─▶ VPS:/srv/app/releases/<sha>
4. ssh deploy@VPS "/srv/app/deploy.sh <sha>"
└─ migrate, switch symlink, restart, health check
Step 1: A Restricted Deploy User
sudo adduser --disabled-password deploy
sudo mkdir -p /srv/app/releases
sudo chown -R deploy:deploy /srv/app
# on your computer: a key used only for deployments
ssh-keygen -t ed25519 -f deploy_key -C "github-actions" -N ""
# add deploy_key.pub to /home/deploy/.ssh/authorized_keys on the VPS
Give this user only what deploys need. If the deploy must restart a service, allow exactly that command with sudo:
# /etc/sudoers.d/deploy (edit with: sudo visudo -f /etc/sudoers.d/deploy)
deploy ALL=(root) NOPASSWD: /usr/bin/systemctl restart app
Never reuse your personal SSH key in CI. A dedicated key can be revoked without affecting anything else (see our SSH key guide).
Step 2: Repository Secrets
In the repository, go to Settings → Secrets and variables → Actions and add:
DEPLOY_HOST: the server's IP or hostnameDEPLOY_KEY: the contents ofdeploy_key(the private key)DEPLOY_KNOWN_HOSTS: the output ofssh-keyscan -t ed25519 YOUR_SERVER, checked against the server's real fingerprint
Pinning the host key prevents the workflow from connecting to an impostor server. Disabling host key checking is a common shortcut that removes this protection.
Step 3: The Deploy Script on the Server
#!/usr/bin/env bash
# /srv/app/deploy.sh <release-id>
set -euo pipefail
REL=/srv/app/releases/$1
cd "$REL"
ln -sfn /srv/app/shared/.env .env
# app-specific steps, e.g.:
# ./bin/migrate
ln -sfn "$REL" /srv/app/current.new && mv -T /srv/app/current.new /srv/app/current
sudo /usr/bin/systemctl restart app
for i in $(seq 1 20); do
curl -fsS http://127.0.0.1:8000/health >/dev/null && { echo "healthy"; exit 0; }
sleep 2
done
echo "health check failed" >&2
exit 1
The symlink switch with mv -T is atomic, so the application never sees a half-copied release. Keep the last few releases for rollback; our zero-downtime deployment guide explains the pattern and how to avoid dropping requests during restarts.
Step 4: The Workflow
# .github/workflows/deploy.yml
name: Test and deploy
on:
push:
branches: [main]
concurrency:
group: deploy-production
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Install and test
run: |
npm ci
npm test
npm run build
- name: Package release
run: tar -czf release.tgz dist package.json package-lock.json
- name: Configure SSH
run: |
install -m 700 -d ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "${{ secrets.DEPLOY_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
- name: Upload and deploy
env:
HOST: ${{ secrets.DEPLOY_HOST }}
SHA: ${{ github.sha }}
run: |
ssh deploy@"$HOST" "mkdir -p /srv/app/releases/$SHA"
scp release.tgz deploy@"$HOST":/srv/app/releases/$SHA/
ssh deploy@"$HOST" "cd /srv/app/releases/$SHA && tar -xzf release.tgz && rm release.tgz && npm ci --omit=dev && /srv/app/deploy.sh $SHA"
Adapt the build and install commands to your stack. concurrency ensures two deploys never run at the same time. Using the commit SHA as the release name makes it obvious which version is live.
Step 5: Approvals and Environments
Under Settings → Environments, create production and add required reviewers. The workflow then pauses before the deploy job until someone approves it. Environment-level secrets keep production credentials separate from staging; a second workflow (or job) can deploy every push to staging automatically (see our staging guide).
Variant: Deploying Docker Images
For containerised apps, build and push an image to a registry in the workflow, then on the server run docker compose pull and docker compose up -d with the new image tag. Tag images with the commit SHA rather than only latest, so you can roll back to a known version (see our Docker guide).
Rolling Back
# on the server: point current at the previous release
ls -1t /srv/app/releases | head
/srv/app/deploy.sh <previous-sha>
Or re-run the workflow for an earlier commit. Database migrations must be backward compatible for rollbacks to be safe.
Security Checklist
- A dedicated deploy user and key, with sudo limited to specific commands.
- Pinned host keys in
known_hosts. - Secrets only in GitHub Secrets or environment secrets, never in the workflow file or logs.
- Pin third-party actions to a version or commit SHA, and keep their use to a minimum.
- Do not run deploy workflows on pull requests from forks.
SkyRainCloud Plans for This Workload
Deploying from GitHub's hosted runners adds no load to your server beyond the deploy itself. If you build on the server or run a self-hosted runner there, choose at least 4 vCores / 16 GB so builds do not slow the live application.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Intel Xeon Platinum 8269CY VPS
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — Intel | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Business websites, small apps, scheduled jobs and bots | Order |
| VPS 2 — Intel | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| VPS 3 — Intel | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| VPS 4 — Intel | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,299/month | High-memory workloads and consolidated production servers | Check stock |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.
Frequently Asked Questions
Can GitHub Actions deploy to my own VPS?
Is it safe to store an SSH key in GitHub Secrets?
Should I disable host key checking in the workflow?
How do I require approval before production deploys?
How do I roll back a bad deploy?
Should I build on GitHub's runners or on the VPS?
How do I prevent two deploys running at once?
concurrency group to the workflow so deploys queue instead of overlapping.