Plenty of web projects still run on a plain dedicated server or VPS, on Ubuntu LTS, with no container orchestrator and no managed platform. Deployment there is still too often done by hand, over FTP or a git pull typed into an SSH session. Between no automation at all and adopting Docker or a PaaS, there’s a middle path that’s widely under-documented: a GitHub Actions workflow that copies files over SSH and restarts the services that need it. This guide walks through that approach for a typical Node.js or PHP application, with no container involved.
Why skip Docker and PaaS platforms for this case
Docker and managed platforms earn their keep when a team runs several heterogeneous environments, needs horizontal scaling, or shares infrastructure across several projects. On a single dedicated server sized for a handful of known applications, that complexity comes with no real payoff: a virtualization layer to maintain, images to rebuild, a registry to manage. A properly scripted, direct SSH deployment covers the essentials: copy the code, install dependencies, switch to the new version, restart the application service.
Preparing the server
The first step is creating a dedicated deployment user, separate from the usual admin account, with access restricted to the project’s own directory. A fresh SSH key pair, specific to this workflow, is generated on the GitHub Actions side, and its public key is added to that user’s authorized_keys file — never to a personal account’s.
sudo adduser --disabled-password --gecos "" deploy
sudo mkdir -p /home/deploy/.ssh /var/www/myapp/releases /var/www/myapp/shared
sudo chown -R deploy:deploy /home/deploy /var/www/myapp
# public key generated with ssh-keygen -t ed25519 on the CI side, added here:
echo "ssh-ed25519 AAAA... deploy-ci" | sudo tee -a /home/deploy/.ssh/authorized_keys
sudo chmod 700 /home/deploy/.ssh && sudo chmod 600 /home/deploy/.ssh/authorized_keys
The releases/ and shared/ layout keeps several deployed versions around and lets a current symlink point to the right release, a scheme proven since the early Capistrano deployment tools and still relevant today.
The GitHub Actions workflow
The workflow triggers on a push to the main branch, builds the project, then syncs files via rsync over an SSH connection whose private key is stored as a repository secret. No sensitive data travels in the clear, and the private key never leaves the job’s execution environment.
name: production-deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci && npm run build
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
- name: Sync files
run: |
RELEASE=releases/$(date +%Y%m%d%H%M%S)
rsync -az --delete ./dist/ deploy@${{ secrets.DEPLOY_HOST }}:/var/www/myapp/$RELEASE/
- name: Switch and restart
run: |
ssh deploy@${{ secrets.DEPLOY_HOST }} 'bash /var/www/myapp/activate-release.sh'
The server-side script
On the server, a shell script points the symlink at the new release and restarts the application service via systemd, without touching the rest of the tree.
#!/bin/bash
set -euo pipefail
cd /var/www/myapp
LATEST=$(ls -1dt releases/*/ | head -n 1)
ln -sfn "$LATEST" current
sudo systemctl restart myapp.service
# keep the 5 most recent releases, drop the rest
ls -1dt releases/*/ | tail -n +6 | xargs -r rm -rf
| Approach | Operational complexity | Makes sense when |
|---|---|---|
| Docker / orchestrator | High | Several environments, horizontal scaling |
| Managed PaaS | Low, but vendor lock-in | Small team, no infrastructure to run |
Manual git pull over SSH | Low but not reproducible | Very occasional project, never critical production |
| GitHub Actions + SSH + releases | Moderate, scripted once | Single dedicated server, needs traceability and rollback |
Environment variables and application secrets
The shared/ directory isn’t just there to save disk space: it’s where files that must never pass through the Git repository live, starting with the application’s .env file. Each new release gets a symlink to that shared file instead of its own copy, which both prevents database credentials from being committed by accident and avoids re-entering those values on every deployment.
RELEASE=releases/$(date +%Y%m%d%H%M%S)
ln -sfn /var/www/myapp/shared/.env "/var/www/myapp/$RELEASE/.env"
ln -sfn /var/www/myapp/shared/uploads "/var/www/myapp/$RELEASE/uploads"
The secrets themselves, whether the SSH private key or a third-party API token the workflow consumes, stay in the GitHub repository’s encrypted secrets, never in a .env file committed anywhere. Only the value strictly needed for the SSH connection passes through the job; the production .env content stays physically on the server and is never copied to or from GitHub.
Checking application health before switching over
Syncing files doesn’t guarantee the application starts correctly with the new code: a forgotten database migration or a missing dependency can easily pass the sync without error and only break on the first real request. Adding a health check before flipping the current symlink avoids exposing a broken release to users.
#!/bin/bash
set -euo pipefail
cd /var/www/myapp
RELEASE_CANDIDATE="$1"
(cd "$RELEASE_CANDIDATE" && php artisan migrate --force)
sudo systemctl start "myapp-candidate@$(basename "$RELEASE_CANDIDATE")"
sleep 2
if curl -sf http://127.0.0.1:8099/health > /dev/null; then
ln -sfn "$RELEASE_CANDIDATE" current
sudo systemctl restart myapp.service
else
echo "Health check failed, switch aborted" >&2
exit 1
fi
This step assumes a dedicated /health endpoint that checks the database connection and critical external services without depending on user data. On a typical PHP project, database migrations run against the new release before the symlink switch, never after: if a migration fails, the previous version stays live and no user ever sees an error.
Rollback and service continuity
The advantage of the successive-releases scheme is that a rollback comes down to pointing the current symlink back at the previous directory and restarting the service, with no fresh full deployment. Restarting through systemd, rather than a plain kill followed by a manual relaunch, guarantees identical behavior between an automated deployment and a manual on-call intervention.
cd /var/www/myapp
PREVIOUS=$(ls -1dt releases/*/ | sed -n 2p)
ln -sfn "$PREVIOUS" current
sudo systemctl restart myapp.service
A rollback that comes down to repointing a symlink is always faster to execute under pressure than an improvised restore procedure.
Key takeaways
A GitHub Actions workflow that deploys over SSH to a dedicated server fills most of the gap between no automation at all and adopting a container orchestrator. The successive-releases layout, the symlink switch, and the systemd restart are enough to get a reproducible deployment and an instant rollback, without adding an infrastructure layer to maintain. This approach pairs naturally with self-managed hosting on a dedicated server and with a hardened server baseline upstream. None of this requires buying into an orchestrator just to get a deployment the team can trust.
I don’t have an automated deployment pipeline in place across all my projects, and I won’t pretend otherwise: part of my work still runs on manual SSH, out of habit and because the client never asked for anything else. This guide is as much a path for my readers as a nudge to myself — the next rebuild will be the occasion to put this scheme in place instead of putting it off one more time. — Simon Janvier
To go further: official GitHub Actions documentation on deployments.
