Deploy Pipeline
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
- Trigger.
workflow_run: the engine’s CI (CI → Build → Deploy) completes successfully for a push tomain. Failed CI and PR runs never deploy.workflow_dispatchre-runs it or names a commit, with an optionalforce. - Target. The exact commit CI tested, never “whatever
mainis now”. - 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 oldbuildFilterlist plus.github/and.claude/. - Deploy. It connects over SSH with a pinned host key as
deployerand sendsdeploy <sha>. The gate re-checks everything, then runs40-app-deploy.ps1with that exact commit (its own release directory, frozen install, server build, migrations with the service environment, switch thecurrentsymlink, restart,/healthgate; the live commit is recorded only after the gate passes). - Verify.
https://api.legendary-arena.com/healthreturns 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
- Deploy Server
: the script the pipeline runs, and the hand-deploy and setup steps (
content/app/deploy-server.mdhas the full runbook). - Ubuntu Droplet Setup
: puts the scripts at
/opt/la-lab/infra. - Render-to-DigitalOcean Migration : the Phase 4 context; this replaces Render’s auto-deploy.
Edge Cases
- Pause deploys by setting the engine repo’s variable
DEPLOY_ENABLEDto anything buttrue. 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-serveronce you trust the commit. - Concurrent deploys queue: one GitHub concurrency group, never cancelled. On the droplet, the gate holds a
flockshared 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_moduleschanges 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
- Engine repo
.github/workflows/deploy-server.ymland DECISIONS D-24708. 41-deploy-user.ps1andla-deploy.ps1: the droplet side.- Deploy Server : hand deploys and the one-time key setup.
docs/PLAN.md: the migration plan this completes.