Skip to content

Example pipelines

Each shows one thing; the comments at the top say what. Pipelines has every key.

File Shows
fiber.yml Three steps in a row, a repository, an artifact
diamond-ci.yml Steps at once, and one that waits for them all
fan-out-tests.yml No repository; labels that choose a runner
release-with-artifacts.yml Files carried down a chain of steps
matrix.yml A matrix, if:, and what is skipped
paths-filtered.yml Runs only when certain files change
cron.yml A nightly schedule
concurrency.yml A push that cancels the build it replaces
env-vars.yml Environment, working_directory, shell, continue_on_error
scoped-secrets.yml Which secrets a step is given

To run one:

Terminal window
fiber validate examples/diamond-ci.yml
fiber pipelines apply examples/diamond-ci.yml --project <project id> # prints the pipeline's id
fiber run <pipeline id> --follow

The steps ask for a runner labelled os=linux, and fan-out-tests.yml also for docker=true: give an agent those labels with fiber agents create --labels. They run on the runner’s host, which it allows with FIBER_AGENT_ALLOW_HOST_SHELL=true, except scan in scoped-secrets.yml, which needs Docker (fiber agent --docker) and a project secret NPM_TOKEN. See runner.

Every one is compiled by packages/domain/test/examples.test.ts, and run on a real runner by apps/runner/e2e/run.test.ts, with a local repository in place of GitHub’s.

# One run a branch: a second push cancels the first build of that branch and leaves every other
# branch alone.
#
# `{pipeline}-{ref}` is the default, written out to show what it is made of: `{pipeline}` is the
# pipeline's id and `{ref}` the branch. Without `concurrency`, or with `cancel_in_progress: false`,
# every push builds: runs are not queued behind each other.
name: concurrency-demo
workspace:
repo: https://github.com/octocat/Hello-World.git
ref: master
on:
push:
branches: [main]
concurrency:
group: "{pipeline}-{ref}"
cancel_in_progress: true
steps:
checkout:
run: test -f README && echo checked-out
labels: [os=linux]
slow-build:
needs: [checkout]
# Long enough for a second push to land while this runs.
run: echo building && sleep 20 && echo built
labels: [os=linux]
publish:
needs: [slow-build]
run: echo publish
labels: [os=linux]
# Six fields, seconds first, in UTC: this is 02:00 every day. A tick missed while the server was
# away is run once, not once for each, and none starts while a run of this pipeline is active.
# `cron` wins over `interval_minutes` when both are set.
name: nightly-cron
workspace:
repo: https://github.com/octocat/Hello-World.git
ref: master
on:
cron: "0 0 2 * * *"
steps:
checkout:
run: ls -la
labels: [os=linux]
build:
needs: [checkout]
run: echo "nightly build"
labels: [os=linux]
# One step, three at once after it, then two in a row. A step starts when everything in its
# `needs` has succeeded.
name: diamond-ci
workspace:
repo: https://github.com/octocat/Hello-World.git
ref: master
on:
push:
branches: [main, develop]
steps:
checkout:
run: ls -la && test -f README
labels: [os=linux]
retries: 1
lint:
needs: [checkout]
run: echo linting && sleep 0.3
labels: [os=linux]
unit:
name: unit tests
needs: [checkout]
run: echo unit && sleep 0.4
labels: [os=linux]
retries: 1
types:
name: typecheck
needs: [checkout]
run: echo typecheck && sleep 0.25
labels: [os=linux]
package:
needs: [lint, unit, types]
run: mkdir -p dist && echo bundle > dist/app.txt
labels: [os=linux]
artifacts: [dist/app.txt]
smoke:
needs: [package]
run: test -f dist/app.txt && echo smoke-ok
labels: [os=linux]
# Environment of the pipeline and of a step.
#
# The step's wins over the pipeline's, and a matrix value over both. These are not secret: they are
# part of the pipeline, which every reader of the project sees. Use secrets for what should not be.
name: env-vars
env:
NODE_ENV: production
LOG_LEVEL: info
steps:
build:
run: |
echo "mode: $NODE_ENV"
echo "log level: $LOG_LEVEL"
mkdir -p apps/ui && echo '{}' > apps/ui/package.json
labels: [os=linux]
artifacts: [apps/ui/package.json]
test:
needs: [build]
# For this step only.
env:
LOG_LEVEL: debug
CI: "true"
run: |
echo "log level: $LOG_LEVEL"
echo "ci: $CI"
labels: [os=linux]
# A step in a monorepo: somewhere else in the tree, in another shell. The directory must be
# there when the step starts: in a repository it is one of its own; here `build` made it.
# `artifacts` are relative to the top of the workspace, not to working_directory.
ui:
needs: [build]
working_directory: apps/ui
shell: bash
run: |
echo "building in $PWD"
echo "bash ${BASH_VERSION%%.*}"
labels: [os=linux]
# Advisory: it fails, and shows as failed, but the run does not fail for it.
lint:
continue_on_error: true
run: exit 1
labels: [os=linux]
# No repository: steps start in an empty directory. Labels choose the runner: a step goes only to
# an agent that has every label the step names.
name: fan-out-tests
on:
push:
branches: [main]
steps:
checkout:
run: echo ready
labels: [os=linux]
test-linux:
name: test linux
needs: [checkout]
run: uname -s && sleep 0.3
labels: [os=linux]
retries: 1
test-docker:
name: test docker labels
needs: [checkout]
run: echo docker-lane && sleep 0.35
labels: [os=linux, docker=true]
integration:
needs: [checkout]
run: echo integration && sleep 0.5
labels: [os=linux]
report:
needs: [test-linux, test-docker, integration]
run: echo green > report.txt
labels: [os=linux]
artifacts: [report.txt]
# Three steps, one after another. The repository is checked out at the commit that started the
# run, or at `ref` when the run was started by hand or by a schedule.
name: build-and-test
workspace:
repo: https://github.com/octocat/Hello-World.git
ref: master
on:
push:
branches: [main]
steps:
checkout:
run: ls -la && test -f README
labels: [os=linux]
retries: 1
build:
needs: [checkout]
run: echo "build in $(pwd)" && echo "artifact payload" > fiber-out.txt
labels: [os=linux]
artifacts: [fiber-out.txt]
test:
needs: [build]
# Each step has a workspace of its own: fiber-out.txt is here because `build` declared it.
run: cat fiber-out.txt
labels: [os=linux]
# A matrix makes one step of each set of values, when the pipeline is saved. Each is told its
# values as MATRIX_<NAME>. `if:` decides, when its turn comes, whether a step runs.
name: matrix-and-if
workspace:
repo: https://github.com/octocat/Hello-World.git
ref: master
steps:
checkout:
run: test -f README
labels: [os=linux]
test:
needs: [checkout]
run: echo "testing on $MATRIX_OS" && test -n "$MATRIX_OS"
labels: [os=linux]
matrix:
os: [linux, macos]
# Only the linux one runs; the macos one is skipped.
if: "matrix.os == 'linux'"
# `needs: [test]` is every step the matrix made. One of them was skipped, so this is skipped too:
# a step without `if:` runs only when everything it needs succeeded.
report:
needs: [test]
run: echo "every cell passed"
labels: [os=linux]
# `always()` runs once what it needs has ended, however it ended.
cleanup:
needs: [test]
run: echo "always cleanup"
labels: [os=linux]
if: "always()"
# Starts for a push or pull request to main only when a source file changed, not for docs alone.
# For a pull request, its files are asked of GitHub with the project's GITHUB_TOKEN secret, which
# needs to read pull requests. Without it, a pipeline filtered by path does not start.
name: paths-filtered
workspace:
repo: https://github.com/octocat/Hello-World.git
ref: master
on:
push:
branches: [main]
paths:
- "src/**"
- "package.json"
- "pnpm-lock.yaml"
paths_ignore:
- "**/*.md"
pull_request:
branches: [main]
paths:
- "src/**"
- "package.json"
- "pnpm-lock.yaml"
paths_ignore:
- "**/*.md"
steps:
check:
run: echo "path filter matched"
labels: [os=linux]
# Files go from step to step as artifacts. A step is given those of every step it needs, directly
# or not: `prod` reads out/VERSION, which `build` made three steps before it.
name: release-with-artifacts
workspace:
repo: https://github.com/octocat/Hello-World.git
ref: master
steps:
checkout:
run: test -f README
labels: [os=linux]
retries: 1
build:
needs: [checkout]
run: |
mkdir -p out
echo v1.0.0 > out/VERSION
tar -cf out/release.tar README out/VERSION
labels: [os=linux]
artifacts: [out/VERSION, out/release.tar]
sign:
needs: [build]
run: echo signed > out/release.tar.sig
labels: [os=linux]
artifacts: [out/release.tar.sig]
staging:
name: deploy staging
needs: [sign]
run: echo staging $(cat out/VERSION)
labels: [os=linux]
retries: 1
canary:
needs: [staging]
run: sleep 0.4 && echo healthy
labels: [os=linux]
prod:
name: deploy prod
needs: [canary]
run: echo prod $(cat out/VERSION)
labels: [os=linux]
# Which of the project's secrets a step is given.
#
# A step with no `secrets:` is given all of them; `[]` is none. A step fails when one it names is not
# set. Naming them keeps credentials from steps that have no use for them, most of all a step in an
# image you do not control. Values are masked as *** in the log either way. A pull request from a
# fork is given none.
name: scoped-secrets
steps:
build:
run: |
echo "no secrets needed here"
mkdir -p out && echo "1.0.0" > out/VERSION
labels: [os=linux]
artifacts: [out/VERSION]
secrets: []
scan:
needs: [build]
run: echo "scanning $(cat out/VERSION) on $(. /etc/os-release && echo "$ID")"
image: alpine:3.22
labels: [os=linux]
secrets: []
publish:
needs: [build]
run: echo "publishing $(cat out/VERSION) with a token of ${#NPM_TOKEN} characters"
labels: [os=linux]
secrets: [NPM_TOKEN]
timeout_minutes: 10