Deploy from GitHub Actions
Prerequisites: a Workload that already runs (created in the console), its service instance id, and the deploy token. Add zaroz-deploy.sh to your repository as deploy/zaroz-deploy.sh.
Secrets and variables
In Settings > Secrets and variables > Actions, create these on the production environment (Settings > Environments):
| Name | Kind | Value |
|---|---|---|
ZAROZ_TOKEN | secret | the zaroz_... deploy token |
ZAROZ_SERVICE | variable | the service instance UUID |
GHCR_PULL_TOKEN | secret | only for a private package: a classic token with read:packages, not the one that pushes |
Environment secrets are only handed to jobs that target that environment, so add required reviewers to production if a human should approve each deploy.
The workflow
Code
How it behaves:
buildpushesghcr.io/<owner>/<repo>:<first 12 chars of the commit>. Each commit gets its own tag.deployruns the script, which fails the job when the rollout fails and has already put the previous image back.concurrencyqueues a second push instead of racing the first. Zaroz would otherwise refuse it with409while the first deployment holds the service.- The job log prints
deployment #N started, then... is servingor thefailure_reason.
Roll back by hand
Re-run the deploy job of an older successful run: it deploys that run's image again. Or from a terminal: IMAGE=ghcr.io/acme/api:<old tag> sh deploy/zaroz-deploy.sh.
Pull requests
Do not give a pull request from a fork access to ZAROZ_TOKEN. The workflow above runs only on pushes to main, where secrets are available. For a preview environment, mint a second token scoped to a separate preview service.
