Habib Ali Machpud
← Case studies

Project case study

Automatic delivery with a concrete way back

Shipping private images from successful main builds through a restricted VPS poller, with serialised deployment and verified rollback.

Problem

After the first manual deployment, Ask Habib needed automatic releases without giving a CI job broad SSH access to production. The repository and container images are private. The account uses GitHub Free, so the design could not depend on private-repository environment controls that were unavailable on that plan.

The desired behaviour was specific: successful main builds should deploy automatically, production changes should be serialised, and a failed rollout should have an identified previous release to restore.

A pull-based boundary

GitHub Actions builds and tests native AMD64 API and web images, publishes them to a private registry, and produces a release manifest tying immutable image digests to a source revision. It holds no production SSH identity.

A root-owned poller on the VPS uses a repository-specific read-only token to inspect the configured release workflow. It checks the workflow identity, repository, branch, event, successful completion, source revision, and bounded release artifact before requesting deployment. Registry pull credentials are separate from the GitHub API credential.

The deployment gateway accepts release data against a fixed Compose policy. It does not execute code downloaded from the repository. It validates allowed image packages, digest pins, platform, revision, and configured container users. Locks serialise deployment changes.

Recovery is part of the operation

The gateway journals current, previous, and pending release state. It pulls and validates images before replacement, checks the internal route, and verifies the public API’s compiled source revision. A failed deployment restores the previous release. The durable pending state also supports recovery after interruption.

Acceptance included a real release, rollback, a hold that prevented the poller from immediately undoing the exercise, and restoration using the exact published artifact. Public checks verified the compiled revision and correlated request IDs with origin logs. A subsequent automatic release and independent public verification passed.

A failure worth preserving

An early production verification request received HTTP 403 when using Python’s default client identity. The verifier was updated to send an explicit deployment-check User-Agent, and a regression test preserved the behaviour. This was a reminder to test the full public path with the actual automation client, not only an internal health endpoint.

Tradeoffs and result

Polling introduces a short delay after publication. The VPS owns a powerful local deployment gateway, so its code, policy, and credentials must remain protected. Tokens expire and require rotation. A successful image rollback also says nothing about restoring a future database; schema compatibility and backups need separate work.

The resulting pipeline automatically deploys successful main releases, checks the running revision, and retains a tested recovery path. ADR-017 records the runtime choice, and the delivery note explains the workflow in more detail.