Skip to content

Trying a branch on staging

Run your branch's build of a service on staging. Deploys run from main only. You build the image from your branch, then merge a PR that pins it. The reference is Deploying staging.

Staging is shared. Your build runs until the next merge that moves the same pin. Tell the team before you pin a branch build.

1. Build the images

Every main commit already has images. For a main commit, skip to step 2.

For another branch, push it. Then dispatch the build from it:

gh workflow run build-service-images.yml --ref <your-branch> -f services="croesus llm-router"
  • services takes service directories or image names. Leave it empty to build every service with an image.
  • DO build only the services you changed. An image of an unchanged service is built from your branch's tree. If your branch is behind main, then pinning it rolls that service back.
  • Each image is tagged with the first 12 digits of the commit. An image already pushed for the commit is not rebuilt, so a re-run builds only what failed.
  • The run summary shows the command for step 2.

2. Pin them

On a fresh branch off main:

git switch -c staging/<your-branch> origin/main
mise run //infra/docker:pin-staging-images <commit>
  • Use gcloud auth login first. The task reads the digests from the platform-staging registry.
  • Name the services to re-pin after the commit. A service is its directory or its image name. pin-staging-images <commit> croesus inference-proxy moves only those two pins.
  • A named service MUST have an image for <commit> and a pin in staging.env. Otherwise the task fails and changes nothing.
  • With no services, it moves every pin that has an image for <commit> and leaves the rest. It does not check what your branch changed.

Only images pinned in staging.env deploy this way. inference-worker's pin is in infra/inventory/staging/config.yml. It is not deployed by this workflow.

To see what was pushed for each commit and what staging pins now:

mise run //infra/docker:list-staging-images              # the 5 newest commits
mise run //infra/docker:list-staging-images -- -n 20     # the 20 newest
mise run //infra/docker:list-staging-images <commit>

It always shows the commits that hold a pinned image, however old. It warns about a pin whose image is not in the registry.

3. Merge

Open a PR with the staging.env change. Merge it. deploy-staging.yml deploys it.

The Terraform comes from main, not from your branch. If your branch changes a service unit, then merge that change first. Otherwise your container can start without a variable it needs.

4. Go back to main

Run steps 1 to 3 for a main commit. Or revert your pin PR.