W2W.SPACE

W2W release and rollback

Set DEPLOY_SERVER explicitly to the SSH target, for example zheyuan_wei2003@w2w.space. There is no built-in IP address. When the domain’s A record changes, SSH follows DNS; keep that record pointed at the real origin server rather than an HTTP-only proxy. Coordinate manual server mutations with the task owner; the configured Actions workflow authorizes releases on main. The server Compose directory has been confirmed as /home/zheyuan_wei2003/CSCC09-24F-Project/remix; scripts still require an explicit DEPLOY_DIR so operators can check the selected installation. The public health URL must be confirmed before release. These scripts do not change SSH authentication, QQ-bot services, certificates, proxy images or trust policy, Redis versions, or the production data schema. The release controller temporarily installs an owned nginx maintenance hook.

GitHub Actions automation

.github/workflows/deploy.yml runs on pushes to main, or through Actions → Deploy W2W → Run workflow with main selected. It validates the exact commit, builds an image, checks it with disposable Redis, publishes its commit tag, and deploys the resulting immutable digest with the existing backup/rollback and internal/public health checks and automatic maintenance window. Only one production run proceeds at a time; an active release is not cancelled by a new push. Merging into main therefore authorizes an automatic production release. Pull requests targeting main run the application validation and shell syntax checks without deployment credentials; they never publish or change the server. Both jobs run the controller/transport unit suite on Python 3.8.18, matching the production Python minor version instead of relying only on the runner default. W2W_TEST_PYTHON selects that test interpreter without changing npm’s build toolchain or the server runtime.

Configure these repository Actions variables under Settings → Secrets and variables → Actions → Variables:

Variable Value
DEPLOY_SERVER SSH target, e.g. zheyuan_wei2003@w2w.space
DEPLOY_DIR /home/zheyuan_wei2003/CSCC09-24F-Project/remix after confirming the installation
RELEASE_HEALTH_URL https://w2w.space/health after confirming public routing
DEPLOY_KNOWN_HOSTS Trusted OpenSSH known_hosts line(s) matching the hostname in DEPLOY_SERVER
W2W_IMAGE_REPOSITORY Optional; defaults to zheyuanwei/w2w

Configure these repository Actions secrets:

Secret Value
DEPLOY_SSH_KEY Private deployment key already authorized for the server account; unencrypted for noninteractive CI
DOCKERHUB_USERNAME Docker Hub account with push access to the image repository
DOCKERHUB_TOKEN Docker Hub access token with the required push access

Verify the SSH host fingerprint through an existing trusted connection or the server console before saving DEPLOY_KNOWN_HOSTS; an unverified ssh-keyscan result alone does not establish trust. Store the private deployment key only in Secrets, never in a variable, source file or log. CI fails before building when required configuration or SSH access is missing. A DNS/IP change on the same host normally keeps the same host key; a replacement host requires independently verifying its new key and updating the pinned record.

The server still needs the reviewed Compose file and runtime .env in place; the workflow deploys the application image and does not synchronize those files. For manual commands, export the same DEPLOY_SERVER, DEPLOY_DIR and RELEASE_HEALTH_URL values in your shell. Local validation/build/publish do not require DEPLOY_SERVER.

Compatibility and release boundary

The independent maintenance page is enabled automatically by release after building and publishing have finished. It returns HTTP 503, including on /health, until the new app passes internal verification. Restoring normal routing must then pass public HTTPS health with the exact commit before the server marks the release complete. The HTML is the approved responsive version; the automation does not change it.

Read-only discovery and prerequisites

Before approving mutations, establish the real absolute Compose directory, Compose project name, running app/Redis containers, image IDs/digests, host architecture, available disk/memory, HTTPS hostname and current behavior. Preserve the existing project identity and automatically loaded Compose override file. The release script edits only the fixed default .env; installations requiring alternate Compose/environment-file selectors need a separately reviewed workflow. Stop if the scripts cannot select exactly the existing services. Do not print full docker inspect, docker compose config, .env or process environments: they can expose credentials. Query only specific non-secret fields.

Use an authorized operator’s existing SSH credentials on their trusted machine. Do not copy private keys into the cloud or change SSH authentication as a release workaround. Verify account isolation and protection of runtime files with the server owner before deployment; retain host-specific security findings in the private operational review. This application release does not change users, groups, sudo policy or file permissions.

The deployment host needs Bash, Docker with Compose v2, Python 3, flock and sha256sum. Local publishing needs Docker Buildx and existing registry access. SSH uses existing credentials, batch mode and strict host-key checking; resolve missing access/host trust instead of weakening checks. The scripts do not provision a new server or synchronize its checkout. Put the reviewed Compose file and secure runtime configuration in place before rollout. Preserve the previous configuration separately if it changes.

Prepare and publish the exact release

Finish and commit the reviewed code first. verify refuses tracked/untracked changes, runs frozen installation, typecheck, lint, build and tests, and records the validated commit in local Git metadata. build runs that validation and builds/loads an image tagged by the full commit; it does not push or deploy.

./deploy-auto.sh build

Before publishing, run the built image against an isolated Redis instance and exercise anonymous sessions, text create/save/read/share, file-token resolution, deletion/undo and relevant authorization failures. Verify /health returns the built revision. Separately test browser/WebRTC and OAuth if those are release acceptance criteria. Record passed, failed and not-run checks; a build alone is insufficient. After artifact validation and publication authorization:

./deploy-auto.sh publish

This publishes the commit tag and prints registry digest references. Select the matching zheyuanwei/w2w@sha256:... reference for release. It does not deploy. W2W_IMAGE_REPOSITORY can explicitly select another approved repository. Existing proxy and CA trust are preserved during builds; TLS verification stays enabled.

Coordinated rollout

Export DEPLOY_DIR as the confirmed absolute Compose directory and RELEASE_HEALTH_URL as the confirmed public HTTPS /health URL. Do not use placeholder values for a real deployment. Export RELEASE_IMAGE as the published digest reference, then run only after coordination:

W2W_RELEASE_APPROVED=1 ./deploy-auto.sh release

The script checks the clean, locally verified commit and packages a fixed list of six public Git blobs: the release controller, maintenance controller, HTML, two nginx snippets, and remix/update.sh. A bounded plain USTAR archive and its manifest have separately pinned SHA-256 checksums. The receiver rejects extra, duplicate, linked or ambiguous paths before staging source in an exclusive private directory. It never transfers .env, credentials or runtime data and does not alter the server checkout. The server requires Python 3.8 or newer.

The server controller holds the shared release lock through maintenance enable, the update and any recovery, and public verification. It refuses an existing manual maintenance window or an unfinished foreign transaction. Its updater inherits the same verified lock descriptor; it cannot release the outer lock. The server script verifies image selection/revision, records the previous app image ID and available registry digests, and keeps a rollback tag. Release records default to $HOME/.local/state/w2w-releases with restrictive permissions. W2W_RELEASE_STATE_DIR can select another protected location when invoking update.sh directly on the server.

Before replacing the app, it snapshots Redis to an RDB, records its checksum, checks the format, and rehearses loading it with the existing Redis image in a disposable container with networking disabled and a read-only backup mount. The production volume is never mounted into that rehearsal. Redis authentication must already be available securely to redis-cli; never put a password in command arguments. Backup/restore failure stops the rollout. Ensure there is enough disk/memory for the backup and temporary Redis before approving it.

After backup verification, the script atomically updates only W2W_IMAGE in the default .env, preserving its other bytes, line endings, owner, group, mode and extended attributes. A temporary file in the same directory is flushed and renamed over .env; no full environment backup is retained in release records or printed. The script checks Compose with W2W_IMAGE unset and allows only the remix.image field to change; proxy, trust, Redis and other settings must match.

The replacement uses compose up -d --no-deps --pull never --no-build remix without a shell image override. The script verifies the running image ID, /health revision and the default image selection. Failed persistence, replacement or internal health triggers app-only rollback and a failing exit status. Recovery uses the actual pre-release container image, even if the old default .env selected a different stale image. If persistence or Docker is also unavailable during rollback, the script reports incomplete recovery and retains the record; it does not claim success.

When internal verification succeeds, the controller removes its maintenance hook and anchor, regenerates/tests/reloads nginx, and checks public HTTPS health and the exact version while still holding the lock. This is the server’s commit point. An error after public restoration that only concerns deleting an already unused owned asset is a cleanup warning, not a failed deployment.

On an update failure, the controller first checks whether the updater recovered the exact previous runtime and default image. Otherwise it requests rollback using only this transaction’s recorded release directory. Maintenance closes only after that recovered revision passes internal and public checks; the release still exits unsuccessfully and reports recovery. Failed recovery keeps the maintenance response and a failing result. A new-version public failure first reinstates and verifies maintenance before attempting rollback. Existing Redis data is never rolled back. Deployment acceptance also requires the normal bounded user-flow smoke test.

SSH disconnection, timeout or a killed process can leave the outcome unknown. The client never automatically resends a release. Inspect the exact transaction, maintenance record, running image and persisted default before recovery. An unfinished transaction blocks automatic takeover even when a process lock is available: Docker may still be completing an already submitted operation. SIGKILL, a host outage and disk failure cannot be made atomic by a shell trap. Do not delete the state, lock, hook or anchor to bypass this protection. Retain the staged source bundle with its recovery records until the incident is closed.

Keep the printed release record, published digest, previous image ID, validation results and release time. No image or backup pruning occurs. After a successful release, ordinary Compose configuration/recreation selects the verified digest from .env; current-image records the same reference. An explicit W2W_IMAGE=... docker compose ... remains available for a separately coordinated override and does not alter the persisted default.

The record’s status distinguishes pending release/rollback from verified completion. Updating a file and replacing a container cannot be one atomic operation: a killed process or host outage can interrupt between them. Before recovery, inspect that record, the actual running image and the default Compose image with the shell override unset; do not infer success from a pending record. Use the coordinated rollback below to restore the recorded previous runtime and its persisted default, then verify public health.

Application rollback

Export RELEASE_RECORD as the exact absolute record directory printed before rollout, and retain the same confirmed DEPLOY_DIR. After coordinating rollback:

W2W_RELEASE_APPROVED=1 ./deploy-auto.sh rollback

Rollback persists the previous runtime’s immutable registry reference when it still resolves to the recorded image ID, or uses that local image ID as the fallback (also supporting older release records). It recreates only remix and verifies that exact image, app health and the default Compose selection without a shell override. For a legacy image without a valid revision label, it verifies the exact image ID and rendered homepage, explicitly reporting that endpoint-based version verification is unavailable. Verify public HTTPS and expected user behavior manually before closing rollback. Keep Redis/proxy unchanged and preserve new user data; rollback never restores an older database automatically.

If an explicit rollback fails after it starts changing the app/default image, the script attempts to restore the actual pre-rollback image and its default. It still exits unsuccessfully and records rollback-failed-restored only when that recovery verifies. If recovery also fails, retain the record and inspect both selections before another coordinated operation.

Backup recovery boundary

The record contains redis.rdb, its SHA-256 checksum, the original Redis image ID and prior application references. Backups contain user data: protect/retain them under the organization’s backup policy. The isolated restore rehearsal verifies loadability before rollout.

Production data restoration is a separate, coordinated recovery operation. Retain the current volume and quiesce all writers; inspect actual Redis dir, dbfilename and AOF settings without exposing credentials. Rehearse recovery with the recorded Redis version and a separate volume. An RDB copy alone does not replace enabled AOF safely. Do not delete/overwrite production volumes or AOF files through this release script. Confirm the specific recovery plan, expected data loss window and rollback volume before switching to recovered data.