Flows
A flow runs several steps as one: build, then test in parallel, then deploy. Each step is a run. Flows in short has the overview; this guide covers the file in depth and how to run it.
The file
version: 1
name: ci
params:
- { name: target, type: choice, options: [staging, production], default: staging }
env: { GOFLAGS: -mod=mod } # for every step
stages:
- name: build
steps:
- name: compile
image: golang:1.24
commands:
- run: |
go build -o bin/ ./...
echo "version=$(git describe --tags)" >> "$FORGE_OUTPUT"
artifacts: [/workspace/bin]
- name: test
steps:
- name: unit
needs: [compile] # starts once compile ends, with its artifacts
image: golang:1.24
command: [make, test]
retry: { max_attempts: 2, on: [failed] }
- name: e2e
if: git.branch == 'main'
template: e2e # one of the project's templates
params: { target: "${params.target}" }
- version must be 1. Unknown fields are errors, with their line.
- stages: 1 to 20, in order. steps: at most 50 in the flow, names unique across it. The file is at most 64 KiB.
- env and secrets at flow and stage level go to every step; the more specific one wins. Template steps keep their template's secrets.
- A step is an inline run, with the fields of a run spec (
image,command,commands,env,secrets,services,artifacts,timeouts, …), or a template:template: NAMEwith an optionalversion(default the latest),paramsandenv.template: "@org/NAME"is one of the organization's templates. See templates and schedules.
Waiting for steps
A step without needs waits for every step of the earlier stages. A step with needs starts as
soon as the steps it names have ended, and gets their artifacts below /workspace back at the
same paths, whatever their result. It can need steps of earlier stages or steps above it in its
own stage. A step only sees the steps it waits for: success(), failure() and steps.NAME.…
look only at those.
Conditions
if is a small expression of Forge's own, not a shell command:
- { name: release, if: "git.tag =~ '^v[0-9]+'", image: alpine, command: [./release.sh] }
- { name: notify, if: failure(), image: alpine, command: [./notify.sh] }
- { name: publish, if: steps.compile.outputs.version != null, image: alpine, command: [./publish.sh] }
- Status functions:
success()(the default),failure(),always()andcancelled()(the flow run is being stopped byfail_fastor its timeout). - Values:
git.*(branch,tag,event,sha, …),env.NAME,params.NAME, andsteps.NAME.result,.exit_code,.outputs.KEYand.commands.CMD.result. - Operators:
==,!=,<,>,=~(a regular expression),&&,||,!, and functions such ascontains(),startsWith()andfromJSON(). - Without a status function, a condition also needs everything before to have succeeded. A step whose condition is false is skipped, which doesn't fail the flow.
A step's changes lists path globs (["**.go", "!docs/**"]): for a flow run from a Git
trigger, the step runs only when a changed file matches.
Outputs and parameters
Steps hand short values on through $FORGE_OUTPUT (see outputs). A later step
uses them as ${steps.NAME.outputs.KEY}. Pass them through env rather than inline in a script,
so the shell treats them as values, not code:
- name: publish
needs: [compile]
image: alpine:3.22
env: { VERSION: "${steps.compile.outputs.version}" }
commands:
- run: ./publish.sh "$VERSION"
params are given when the flow runs (string, number, boolean or choice, with a
default or required: true). Use ${params.NAME} in env and step fields, and params.NAME
in conditions. A top-level outputs: names the flow run's own outputs, made of step outputs and
parameters.
Matrix steps
A matrix runs the step once for each combination of values. Each run is an instance:
- name: test
matrix:
go: ["1.24", "1.25"] # quote versions
os: [linux, windows]
exclude:
- { go: "1.24", os: windows }
max_parallel: 2
fail_fast: true
image: golang:${matrix.go}
env: { GOOS: "${matrix.os}" }
command: [make, test]
include adds keys to matching combinations or adds combinations of its own. parallel: 4 is
short for four instances, for splitting tests. The step fails if any instance failed, and a
matrix step's output is a JSON array of its instances' values. Your organization's quotas limit
the keys, combinations and step runs of a flow run.
Failures, retries and approvals
- retry is a run retry policy (
max_attempts,initial_delay_seconds,max_delay_seconds,on). The attempts count as one step. - allow_failure:
true, or{ exit_codes: [1, 2] }. An allowed failure shows as Failed (allowed) and doesn't fail the flow run. A cancelled step is never allowed. - fail_fast: true at the top stops the flow run at the first failure that isn't allowed:
running steps are cancelled and the rest skipped, except steps with
always()orcancelled(). - timeout_seconds at the top limits the whole flow run, at most 7 days.
- An approval step runs nothing and waits for an environment's reviewers:
{ name: sign-off, approval: { environment: production } }. Rejected, it fails the flow run unless it hasallow_failure: true. See environments and deploys.
A flow can also have a concurrency group, so only one flow run of the group runs at a time.
Check and run
forge flow check .forge/ci.yaml # no server needed
forge flow run .forge/ci.yaml # follow it
forge flow run -d --param target=production ci.yaml
forge flow run --flow ci # a saved flow
forge flow show FLOW_RUN
forge flow cancel FLOW_RUN
forge flow run exits 0 when the flow run succeeded, 1 when it failed, 124 when it timed out and
130 when it was cancelled. Every step is checked before anything starts, so a flow that can't run
fails at once with the step named.
In the console, the project's Flows tab lists Saved flows and Flow runs. Run a file takes a pasted or opened file; New flow saves one with versions, which schedules and Git triggers can start. A flow run's page shows the stages as columns of steps.
The Builder tab edits the same file as the YAML tab: Add stage, step cards, a panel per step, and Flow settings for the name, parameters, env, secrets and fail fast.


Re-run failed steps
On an ended flow run, Re-run failed steps runs the failed, rejected and cancelled steps again, with every step that waits for them. Re-run on a step does that for one step. The others keep their results, outputs and artifacts.
forge flow rerun FLOW_RUN # the failed steps
forge flow rerun --step unit FLOW_RUN # one step and what waits for it
Run a flow on your machine
forge flow run --local .forge/ci.yaml runs the steps with your own Docker, in file order, all on
your checkout. --parallel N runs up to N at a time, --env-file gives variables and secrets.
There is no sandbox, so only run files you trust. Approval, VM and compose steps and saved flows
don't run locally, and retries are left out.