2026-11-01 · Coding & Dev · Tutorial

Putting a Static Site on Rails: GitHub Private Repo + ConoHa VPS + Caddy Deploy Pipeline

This site started in a fragile state: the homepage files sat in a directory on the VPS, and Caddy served them directly. It worked, but there was exactly one copy in the world. If the VPS disk died, the files were gone; if I shipped a bad edit, there was no old version to roll back to. This article documents how I fixed that: code lives in a private GitHub repository, the VPS pulls from it to deploy, and shipping becomes three steps — edit, push, git pull.

The shape of it

  • Private GitHub repository: the code and its full history — the single source of truth
  • ConoHa VPS (1GB RAM / 2 cores / 100GB SSD): a clone of the repo at /var/www/tinkerdesk
  • Caddy: two lines of config at the core — root * /var/www/tinkerdesk plus file_server; static files take effect the moment they change, no restart

Step 1: create the repo — and verify it's Private first

GitHub defaults new repositories to Public. I nearly pushed a redesign draft into a public repo and only caught it by checking the visibility through the API before pushing. Lesson: verify the repo is Private before the first push, especially if it will hold unpublished drafts. Private repos are free; there is no reason not to.

Step 2: split the Deploy Keys

Two machines need access to the private repo. Both use Deploy Keys (scoped to a single repo, revocable any time), but with different rights:

  • My dev machine: write access, for pushing new versions
  • The VPS: read-only, for pulling deploys. A server only ever needs to read — never give it write access

One more gotcha: a GitHub Deploy Key cannot be reused across repositories — one key binds to exactly one repo. A fresh key per project looks like a hassle, but it is exactly the isolation you want: retire a project, delete its key, nothing else is affected.

Step 3: swap the VPS directory for a clone

Don't delete the old directory — rename it as a backup, then clone the repo into its place:

mv /var/www/tinkerdesk /var/www/tinkerdesk.bak-20261101
git clone git@github.com:<account>/tinkerdesk-site.git /var/www/tinkerdesk

After the swap, compare old and new files byte for byte and confirm the live content is identical before calling it done. Keep the old directory around: if anything breaks, one mv brings it back. A side benefit: an old backup file that used to be reachable by URL inside the web root returned 404 after the swap — files that should not be public don't belong in the web root.

The daily flow

# dev machine: after editing
git push
# VPS: deploy
cd /var/www/tinkerdesk && git pull --ff-only

Rollback is the same shape: find the last good version in git log and check it out, or revert in the repo and pull again. The history is the backup.

War story: commands on the wrong machine

The first launch of a new version looked successful — my check returned HTTP 200 — yet the live site was still the old one. What had happened: the SSH session had dropped mid-task, and every later command ran on my local machine, while the check I used returns 200 from anywhere, masking the failure. Two lessons:

  • Know which machine your terminal is on — the local and server prompts look completely different
  • Verify a deploy by content or version (the commit at the top of git log, the byte size of the page), never by status code alone — the old version happily returns 200 too

Summary

No fancy tooling anywhere: one private repo, two Deploy Keys with split rights, two lines of Caddy. In return: an off-site backup, full history, and one-command rollbacks. For a personal site, that trade is well worth it.