Legendary Arena Lab

Deploy Pipeline

wiki

Deploy Pipeline

Production has run on the droplet since the 2026-10-12 cutover. The engine records it as D-24707 (the move) and D-24708 (this pipeline).

Summary

The game server deploys itself after CI passes on the engine repo’s main. The workflow lives in the engine repo, which owns the trigger and the path filter: .github/workflows/deploy-server.yml. This repo owns the droplet side: the restricted deployer user (41-deploy-user.ps1 ), the gate it is pinned to (la-deploy.ps1 ), and the one deploy script everything calls (40-app-deploy.ps1 ). Hand deploys, CI deploys and the provision smoke test all run that same 40 path.

Mechanics

  1. Trigger. workflow_run: the engine’s CI (CI → Build → Deploy) completes successfully for a push to main. Failed CI and PR runs never deploy. workflow_dispatch re-runs it or names a commit, with an optional force.
  2. Target. The exact commit CI tested, never “whatever main is now”.
  3. Decide. The workflow asks the droplet for the live commit (status). It skips if the target is already live or older than live, or if no server-relevant file changed between them. These don’t count: wiki/, docs/, .github/, .claude/, and the front-end apps, which is Render’s old buildFilter list plus .github/ and .claude/.
  4. Deploy. It connects over SSH with a pinned host key as deployer and sends deploy <sha>. The gate re-checks everything, then runs 40-app-deploy.ps1 with that exact commit (its own release directory, frozen install, server build, migrations with the service environment, switch the current symlink, restart, /health gate; the live commit is recorded only after the gate passes).
  5. Verify. https://api.legendary-arena.com/health returns 200 through Cloudflare.

What the CI key can do. Only status and deploy <a commit on origin/main, not older than live>. There’s no shell, no forwarding (restrict), and no other sudo. A leaked key can only redeploy code already on main, and a slow CI run can’t roll production back.

Why it isn’t in this repo any more (2026-10-12). The first pipeline (deploy.yml here, removed in lab PR #33) was manual-only and logged in as operator, which has full passwordless sudo. A trigger in this repo also can’t see engine pushes. The engine-side workflow plus the gate replaced it, and it was never enabled.

Interactions

Edge Cases

  • Pause deploys by setting the engine repo’s variable DEPLOY_ENABLED to anything but true. Nothing else needs editing.
  • Roll back with a hand deploy on the droplet: sudo DEPLOY_REF=<older sha> pwsh -File scripts/40-app-deploy.ps1. The gate refuses older commits by design, so CI can’t do it. Alternatively, revert the PR on GitHub; the revert’s merge deploys.
  • Flaky CI blocks the deploy (nothing ships on a red run). Re-run CI, or dispatch deploy-server once you trust the commit.
  • Concurrent deploys queue: one GitHub concurrency group, never cancelled. On the droplet, the gate holds a flock shared with hand deploys.
  • A failed build or migration stops before the restart. The old process keeps serving, but the build is in place, so node_modules changes underneath it. Blue/green directories are the fix if that ever bites.

Execute

gh workflow run deploy-server.yml -R barefootbetters/legendary-arena                 # current main
gh workflow run deploy-server.yml -R barefootbetters/legendary-arena -f force=true   # even if only docs changed

Verify

gh run list --workflow deploy-server.yml -R barefootbetters/legendary-arena

A green run with the deploy step taken means 40 saw /health 200 on the droplet, and the public check passed. On the host: journalctl -t la-deploy -n 20 (the gate’s record) and systemctl status la-server.

References