Steps and pipelines from another repository
Use a composite step or a reusable pipeline that another repository publishes, pinned to a version.
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.yamlor.xeonr-ci.yaml. See What is available.
Not yet available (xeonr/forge/steps): the shared step repository has released
v1(tagsv1.0.0andv1.0.1) but is still private, visible only to its own team, until its visibility is set to organisation. Until then a reference to it from any other repository is refused as a repository you cannot read; the example below is how it will be used. A step repository of your own works today if its visibility is company or organisation: a private repository's steps are usable by that repository alone.
xeonr/forge/steps holds steps no product owns, for every repository to
use. In the publishing repository:
# xeonr/forge/steps: .branchd/packages.yaml
# What other repositories may use from xeonr/forge/steps. It is read at the head
# of the default branch, never at the commit being used.
packages:
- setup-buf
- .branchd/pipelines/deploy.yaml
# xeonr/forge/steps: setup-buf/step.yaml
# Used from another repository as xeonr/forge/steps/setup-buf@v1.
name: Set up buf
description: Installs buf.
inputs:
version: {type: string, default: '1.56.0'}
outputs:
path: ${{ steps.install.outputs.path }}
steps:
- id: install
run: |
curl -fsSLo /usr/local/bin/buf \
"https://github.com/bufbuild/buf/releases/download/v${{ inputs.version }}/buf-$(uname -s)-$(uname -m)"
chmod +x /usr/local/bin/buf
echo "path=/usr/local/bin/buf" >> "$BRANCHD_OUTPUT"
# xeonr/forge/steps: .branchd/pipelines/deploy.yaml
# Used from another repository as
# xeonr/forge/steps/.branchd/pipelines/deploy.yaml@v1. Its jobs run as the
# calling repository, with the secrets the calling job passes.
on:
call:
inputs:
environment: {type: choice, options: [stage, production], default: stage}
secrets:
DEPLOY_TOKEN: {required: true}
jobs:
apply:
image: alpine:3
environment: ${{ inputs.environment }}
secrets: [DEPLOY_TOKEN]
steps:
- run: echo "deploying to ${{ inputs.environment }}"
In the repository that uses them:
# .branchd/pipelines/ci.yaml
# Uses a composite step and a reusable pipeline of xeonr/forge/steps, each at the
# newest v1.x.y tag. The deploy pipeline chooses its environment, which
# this job allows.
name: CI
on:
push:
branches: [main]
jobs:
lint:
image: golang:1.26
steps:
- id: buf
uses: xeonr/forge/steps/setup-buf@v1
with: {version: '1.57.0'}
- run: ${{ steps.buf.outputs.path }} lint
deploy:
needs: [lint]
uses: xeonr/forge/steps/.branchd/pipelines/deploy.yaml@v1
allow: [environment]
with: {environment: production}
secrets: [DEPLOY_TOKEN]
The reference
<group>/<repo>/<path>@<version>. <path> is a directory holding
step.yaml (a step), or a .yaml file declaring on: call (a pipeline),
by its path from that repository's root. A repository's own path can have
several levels; the shortest leading part of at least two segments that is a
repository you can read is the repository.
Versions
Versions are tags, resolved to one commit when the run is compiled:
| You write | It is |
|---|---|
@v1 | the newest tag v1.x.y |
@v1.4 | the newest tag v1.4.y |
@v1.4.2 | exactly that tag |
@1, @1.4, @1.4.2 | the same, for tags without the v |
@<40-character commit> | that commit, if it is a version tag's commit or on the default branch |
@main | refused: what runs must be fixed by a tag |
Only tags of the form [v]X.Y.Z count, with no leading zeros:
v1.5.0-rc1 is never picked. Nobody has to move a v1 tag. The run
records the tag and commit each reference resolved to, and
branchd ci plan prints them.
packages.yaml: what may be used
The publishing repository lists what others may use in
.branchd/packages.yaml, read at the head of its default branch (never at
the commit being used, so a commit cannot list itself). A reference to a
path it does not list is refused, and so is any reference to a repository
without the file. Inside a used step or pipeline, ./<name> is the
publisher's own .branchd/steps/<name>, which need not be listed.
Who may use it
The publishing repository's visibility, judged for your repository (never for the person who pushed):
| Its visibility | Usable by |
|---|---|
| Private | That repository only: not even the other repositories of its team |
| Company | Every repository of a team the same company owns |
| Organisation | Every repository of the organisation |
| Public | Any repository |
So to share steps, pipelines or a preset, give the repository company or organisation visibility. A repository you cannot read is refused exactly as one that does not exist, so the message never says which it was.
- A nested reference (a used step that uses another) must be readable by every repository in the chain, yours and each after it: a publisher cannot pull in what you may read and it may not.
- The job token plays no part: branchd reads the other repository when the run is compiled, as your repository. At run time the token still reads only your own.
Consent: what another repository's pipeline may choose
A called pipeline of another repository runs as your repository, so it may not choose for you, unless the calling job allows it:
environment:on one of its jobs needsallow: [environment]on the calling job (or setenvironment:on the calling job yourself);trigger:jobs in it needallow: [trigger];- runner labels (
runs-on) it asks for must each be listed in the calling job's ownruns-on, which lends them.
What you trust
A step of another repository runs in your job's shell, with your job's secrets, job token and workspace. A pipeline of another repository is that team's jobs running as your repository, with the secrets you pass it. Use one only from a repository whose code you would run yourself. See Security.
Limits: at most 32 different references to other repositories in a run, and the limits of composite steps, which count these uses too.