# Pipelines

> What a branchd pipeline is, what is available today, and where each task and key is documented.
> **Available** in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its `.forge-ci.yaml` or `.xeonr-ci.yaml`. See [What is available](https://docs.branchd.run/branchd/pipelines#what-is-available).

A pipeline is a YAML file in your repository, `.branchd/pipelines/<name>.yaml`,
that says when it runs (`on:`) and which jobs it runs (`jobs:`). Each job runs
its steps in a container, with your repository already checked out. Jobs run
in parallel unless one `needs` another. Everything about which jobs run is
decided before the run starts, so `branchd ci plan` can tell you, for any
branch or event, which jobs will run and why.

The syntax follows GitHub Actions closely: `on`, `jobs`, `steps`, `needs`,
`if`, `matrix`, `${{ }}` expressions and `uses:`. It is not GitHub Actions:
the differences are in [Coming from GitLab CI](https://docs.branchd.run/branchd/pipelines/from-gitlab-ci)
and throughout the [reference](https://docs.branchd.run/branchd/pipelines/reference).

## For agents and editors

- **The complete reference in one file**, as Markdown:
  [`/branchd/pipelines/reference.md`](https://docs.branchd.run/branchd/pipelines/reference.md).
  Every key, every refusal rule and every limit, on one page.
- **Every page of this section in one file**:
  [`/branchd/pipelines/llms-full.txt`](https://docs.branchd.run/branchd/pipelines/llms-full.txt),
  with an index at [`/branchd/pipelines/llms.txt`](https://docs.branchd.run/branchd/pipelines/llms.txt).
  The site's own index is [`/llms.txt`](https://docs.branchd.run/llms.txt).
- **The JSON Schema** of a pipeline file, for editors:
  [`https://docs.xeonr.io/schemas/branchd/pipeline.json`](https://docs.branchd.run/schemas/branchd/pipeline.json)
  (and [`step.json`](https://docs.branchd.run/schemas/branchd/step.json), [`packages.json`](https://docs.branchd.run/schemas/branchd/packages.json)).
  See [Editor support and the schema](https://docs.branchd.run/branchd/pipelines/schema).
- **The loop for an agent writing a pipeline**: [Writing pipelines with an AI agent](https://docs.branchd.run/branchd/pipelines/ai-agents).

Every YAML example in these pages is a file that branchd's compiler accepts:
the examples are compiled for every event they list before the pages change.

## Start here

- [Quick start (five minutes)](https://docs.branchd.run/branchd/pipelines/quickstart): Add a pipeline, check it locally, push it, and read its checks.
- [Concepts](https://docs.branchd.run/branchd/pipelines/concepts): Pipeline, run, job, step, needs, the checkout, and what is decided before a run starts.

## Tasks

Each page is one task and one complete file you can copy.

- [Run tests on a pull request](https://docs.branchd.run/branchd/pipelines/test-on-pull-request)
- [Build and push an image](https://docs.branchd.run/branchd/pipelines/build-and-push-an-image)
- [Run a job for several versions (matrix)](https://docs.branchd.run/branchd/pipelines/matrix)
- [Reuse a step](https://docs.branchd.run/branchd/pipelines/composite-steps)
- [Call a pipeline](https://docs.branchd.run/branchd/pipelines/reusable-pipelines)
- [Run on a schedule](https://docs.branchd.run/branchd/pipelines/schedules)
- [Trigger another repository's pipeline](https://docs.branchd.run/branchd/pipelines/trigger-another-repository)
- [A manual pipeline with inputs](https://docs.branchd.run/branchd/pipelines/manual-runs)
- [Use the job token (curl and git)](https://docs.branchd.run/branchd/pipelines/job-token)
- [Isolate a step from the job](https://docs.branchd.run/branchd/pipelines/isolated-steps)

More tasks: [a Go service with a database](https://docs.branchd.run/branchd/pipelines/test-go-with-database),
[a Node.js project](https://docs.branchd.run/branchd/pipelines/test-node),
[deploy](https://docs.branchd.run/branchd/pipelines/deploy),
[caches and artifacts](https://docs.branchd.run/branchd/pipelines/caches-and-artifacts),
[outputs](https://docs.branchd.run/branchd/pipelines/outputs),
[secrets](https://docs.branchd.run/branchd/pipelines/secrets),
[environments and approval](https://docs.branchd.run/branchd/pipelines/environments-and-approval),
[paths](https://docs.branchd.run/branchd/pipelines/paths),
[several pipelines](https://docs.branchd.run/branchd/pipelines/several-pipelines),
[steps and pipelines of another repository](https://docs.branchd.run/branchd/pipelines/other-repositories),
[presets](https://docs.branchd.run/branchd/pipelines/presets).

## Reference

- [Pipeline file reference](https://docs.branchd.run/branchd/pipelines/reference): Every key, in one page.
- [Expressions](https://docs.branchd.run/branchd/pipelines/expressions): ${{ }}, contexts, functions and variables.
- [Step files](https://docs.branchd.run/branchd/pipelines/step-files): step.yaml and .branchd/packages.yaml.
- [Limits](https://docs.branchd.run/branchd/pipelines/limits)
- [Refusals](https://docs.branchd.run/branchd/pipelines/errors): What the compiler refuses, and what to write instead.
- [Troubleshooting](https://docs.branchd.run/branchd/pipelines/troubleshooting): A refused push, a job that does not run, a check that never reports.

## What is available

Pipeline files are on in production, and branchd is switching repositories
to them one at a time. A repository that is not switched on runs its
`.forge-ci.yaml` or `.xeonr-ci.yaml` exactly as before, and ignores
`.branchd/pipelines/`. In a repository that is switched on:

| Part                                                                                                             | State     |
| ---------------------------------------------------------------------------------------------------------------- | --------- |
| Jobs, steps, `needs`, `if`, matrix, services, caches, artifacts, secrets, environments, manual jobs, superseding | Available |
| The automatic checkout (no git needed in the image)                                                              | Available |
| Push checks: a push whose changed pipeline file does not compile is refused, with file and line                  | Available |
| Manual runs with inputs, schedules, triggers of this repository's own pipelines                                  | Available |
| Composite steps and reusable pipelines, of this repository or another                                            | Available |
| Typed steps (`uses: branchd/steps/<step>@v1`), alone or `isolated: true` among `run:` steps                      | Available |
| The job token and `permissions:`                                                                                 | Available |
| Presets of another repository (`preset: {uses: <group>/<repo>/<path>@v1}`)                                       | Available |
| Optional secrets of a step                                                                                       | Available |

**Not available yet**, each said again on the page it concerns:

- **Triggering another repository's pipeline** works only when that
  repository is switched on too; today a trigger to any other repository is
  refused. A repository triggering its own pipelines works.
- **A preset of the same repository** (`preset: {uses: ./<path>}`) is
  refused; a preset comes from another repository.
- **Starting a manual run with inputs from the console**: the console starts
  a run of a branch only. Use the CLI or the API ([Manual runs](https://docs.branchd.run/branchd/pipelines/manual-runs)).
- **The CLI features these pages use**, `branchd run start --pipeline … --input …` and `branchd ci lint` checking every event a file lists, are in
  the next CLI release (0.39.0). `branchd ci lint` and `ci plan` of earlier
  releases (0.33.0 and later) read pipeline files, but check fewer situations.
- **Refused for now**, each with a clear message: `max-parallel`,
  `fail-fast: true`, a `matrix:` on a job that calls a pipeline, a lock over
  a whole pipeline (`concurrency.group` at the top level), `checkout:
  {submodules}`, a job `if:` that reads another job's outputs, a step `if:`
  that reads `steps.*.outputs`.
- **Steps published by other products** (`uses: strata/migrate@1`).
- **A `run:` job's outputs as an `image:` or a typed step's `with:`**: only a
  typed step's outputs reach those ([Outputs](https://docs.branchd.run/branchd/pipelines/outputs)).
- **The branchd CLI inside a job**: it is not in job images. A job can
  install it with `curl -fsSL https://updater.xeonr.io/96/install.sh -o
  install.sh && env -u BRANCHD_TOKEN sh install.sh` (the installer reads
  `BRANCHD_TOKEN` as its own token, so the job's token is left out). The job
  token also works with `curl` and `git`
  ([The job token](https://docs.branchd.run/branchd/pipelines/job-token)).

Source: https://docs.branchd.run/branchd/pipelines
