How-to
CI/CD release gate
Updated
On this page
Make your deploy pipeline ask Zof before it ships. Setting it up takes about 10 minutes: one token, one secret and one step in your deploy job.
What it does
Before a deploy, your pipeline asks Zof: "may this commit ship to this environment?" Zof answers from the checks on the commit's pull request, the same checks the Zof / Control check on GitHub shows. The step passes only when Zof allows the deploy.
If Zof can't answer, for example it can't be reached, the token is wrong or the answer can't be read, the step fails and the deploy stops. There is no fail-open mode: anything other than a valid pass fails the job.
The one deliberate way past a block is break-glass. It deploys whatever the verdict, with a reason you give, and Zof records it as deployed without a Zof decision. It needs a separate break-glass token in ZOF_BREAK_GLASS_TOKEN, issued by an admin. In GitHub Actions, set the break-glass input to the reason; elsewhere, pass --break-glass "<reason>". When break-glass isn't available to your company, the gate refuses it and the deploy stays blocked.
Before you start
- You are a company admin.
- Your GitHub repository is connected to Zof. See Connect GitHub.
- The gate is turned on for your company. If Settings › Pipeline tokens isn't in your settings menu, it isn't on yet. Ask us at support@zofai.com.
For a guided setup, open Add Zof to your deploy pipeline from Setup. It takes you through the steps below one at a time, fills in your environment and repository, and shows when Zof gets the first call from your pipeline.
Or open Integrations and choose your CI under CI/CD: GitHub Actions, Jenkins, CircleCI or Azure Pipelines. Its page runs the same steps for that CI and says Connected once Zof gets a call from it. GitLab CI/CD isn't on Integrations yet; the GitLab step below works today for code on GitHub.
Create a pipeline token
- Go to Settings › Pipeline tokens and click Create token.
- Enter a Name, such as "Deploy job", and choose when it Expires in: 7, 30 or 90 days.
- Under Where it can deploy, choose Only these environments and tick each one, or Any environment.
- Click Create.
- Click Copy now: Zof shows the token only once. Then click I have copied it.
Add the token to your CI
Save the token as a secret named ZOF_GATE_TOKEN in your CI. In GitHub Actions, that is a repository or environment secret. In GitLab, make it a masked, protected CI/CD variable. Never paste the token into a pipeline file.
Add the gate step
Add the step to your deploy job, before the deploy itself. The gate finds Zof by itself; you don't set an address.
GitHub Actions
- uses: zof-ai/gate@v1
with:
environment: production
token: ${{ secrets.ZOF_GATE_TOKEN }}
The step fails the job unless Zof allows this commit to this environment, and writes the answer, the reasons and a link to Zof in the job summary. Optional inputs: max-wait, the minutes to wait for an answer (1 to 60, default 10), and break-glass, a reason (needs ZOF_BREAK_GLASS_TOKEN). Outputs: result (pass, fail or error), exit-code and console-url. For the strictest pinning, use a release tag's full commit SHA instead of @v1.
GitLab CI
zof_gate:
stage: deploy
image: ghcr.io/zof-ai/gate:1
script:
- zof-gate --environment production --repo example-org/example-app
Pass --repo with the GitHub repository Zof checks; the GitLab project path is not it. Name the environment itself: GitLab sets $CI_ENVIRONMENT_NAME only on a job that has its own environment:. For a fixed build, pin the image digest from the gate's release notes: ghcr.io/zof-ai/gate:1@sha256:<digest>.
Other CI with containers
For Bitbucket Pipelines, Jenkins, CircleCI, Azure Pipelines and others, run the image. It is linux/amd64 only for now.
docker run --rm -e ZOF_GATE_TOKEN \
ghcr.io/zof-ai/gate:1 \
zof-gate --environment production --repo example-org/example-app --commit "$GIT_COMMIT" --run-id "$BUILD_ID"
Any CI with Node
With Node 22 or later:
npx @zof-ai/gate --environment production --repo example-org/example-app
Pass --repo with the GitHub repository Zof checks. The gate reads the commit and run from GitHub Actions, GitLab CI, Bitbucket Pipelines, Azure Pipelines, Jenkins and CircleCI. When one is missing, it stops and names the flag to pass: --repo, --commit, --run-id or --environment. zof-gate --help lists every flag.
Check that it worked
Run your deploy job on a commit from a pull request Zof checked. The gate step's log starts with Zof gate:, the repository, the commit and the environment, and ends with Zof's answer and a link to the change in Zof. In Settings › Pipeline tokens, the token's Last used shows when it was used and for which repository. The last step of Add Zof to your deploy pipeline says Connected once Zof has a call from your pipeline.
What you'll see
| Result | What happened | What happens to the deploy |
|---|---|---|
| Allowed | Zof allows this commit to this environment. The log reads "Passed". | The step passes and the deploy continues. |
| Blocked | Zof doesn't allow it. The log lists each reason, for example a unit test that failed, and links to the change in Zof. | The step fails and the deploy stops. Fix the reasons, then run the job again. |
| Waiting | A check is still running, a missing test is starting, or the change needs an approval. The log reads "Waiting for evidence" or "Waiting for approval" and says until when. | The step keeps waiting, up to your company's wait limits. |
| Timed out | The checks or the approval didn't arrive in time. | The step fails and the deploy stops. This is safe by design: run the job again once the checks finish. |
When waiting can't help, for example a test failed or a check can't run, Zof blocks at once instead of making the job wait. The log says "Waiting can't unblock this deploy."
The step's exit code says why it ended:
| Exit code | Meaning |
|---|---|
| 0 | Pass: a stored Zof decision, a baseline or a recorded break-glass. |
| 1 | Blocked. A timeout is a block too. |
| 2 | Usage or configuration error, such as a missing flag or ZOF_GATE_TOKEN. |
| 3 | Zof unavailable. This is never a pass. |
| 4 | Token problem. |
Gate settings
An admin sets these under Gate settings on Settings › Pipeline tokens, then clicks Save. They apply to every pipeline in your company.
- Wait for missing tests (minutes): how long the gate waits for checks that are still running or starting, 1 to 60.
- Wait for approval (minutes): how long the gate waits for a required approval, 1 to 60.
- Start missing tests automatically: when a check the release policy needs hasn't run on the commit, Zof starts it and the gate waits for it.
- Most runs Zof starts per day: the most tests the gate starts for your company in a day, 0 to 500. After that, the gate fails instead of starting more.
A job waits no longer than its own max-wait either. While it waits, your CI job stays open. The gate adds no charge; the test runs it starts are billed as usual.
Troubleshooting
"ZOF_GATE_TOKEN is not set". The step can't see the secret. Check the secret's name is exactly ZOF_GATE_TOKEN and that the deploy job can read it, for example a protected GitLab variable on an unprotected branch can't.
"Zof has no change for this commit". Zof hasn't checked a pull request with this commit. Deploy a commit that came through a pull request Zof checked.
"This commit is no longer the pull request's head". A newer commit was pushed. Deploy the pull request's current head.
Timed out. The log reads "Timed out waiting for evidence", "Timed out waiting for approval" or "didn't arrive within your company's wait limit". The checks or the approval took longer than your wait limit. Open the change in Zof from the log's link to see what is still running, then run the job again. If your checks usually take longer, raise the wait in Gate settings.
"unauthorized: missing or invalid pipeline token". The token was revoked, mistyped or isn't a pipeline token. Pipeline tokens start with zgt_. Create a new one and update the ZOF_GATE_TOKEN secret.
"token_expired: this pipeline token has expired". Create a new token in Settings › Pipeline tokens and update the secret.
"environment_not_allowed: this token is not allowed for this environment". The token was made for other environments. Create a token that lists this one, or one for any environment.
"gate_not_enabled: the pipeline gate is not turned on for this company". Ask us at support@zofai.com to turn it on.
"Zof unavailable". Zof couldn't be reached or sent an answer the gate couldn't read. The gate already retried. Run the job again in a minute.
Security
- A pipeline token belongs to one company and can only ask the gate. It can't read or change anything else.
- Any admin can Revoke a token at any time. Jobs using it stop at once. You can't undo a revoke, so make a new token if you need one.
- The gate sends the token only to Zof, and never prints it in your logs.
- The npm package is published with provenance and the image is signed. The gate's release notes give the commands to verify what you run.