# Trigger another repository's pipeline

> Start a run of a pipeline in another repository, at its own ref and with its own secrets, and optionally wait for its result.
> **Available** for repositories using branchd pipeline files. A trigger job starts a named pipeline in the target repository.

In the repository that starts it:

```yaml title=".branchd/pipelines/ci.yaml"
# .branchd/pipelines/ci.yaml
# After a release on main, start the documentation site's build pipeline
# in acme/docs, and take its result as this job's.
name: CI
on:
  push:
    branches: [main]
jobs:
  build:
    image: golang:1.26
    steps:
      - run: go build ./...
  docs:
    needs: [build]
    trigger:
      repo: acme/docs
      pipeline: build
      ref: main
      inputs:
        product: notify
      wait: true
```

In the repository it starts, `acme/docs`:

```yaml title=".branchd/pipelines/build.yaml"
# .branchd/pipelines/build.yaml
# In acme/docs: may be started by any repository of the same company, with
# one input. It also runs on its own pushes to main.
name: build
on:
  push:
    branches: [main]
  trigger:
    from: company
    inputs:
      product:
        type: string
        default: all
jobs:
  site:
    image: node:24
    steps:
      - run: npm ci
      - run: npm run build -- --product "${{ inputs.product }}"
```

- **Which runs may trigger.** Only a push to, or a manual run of, a
  **protected branch**, by a person, an agent or the team's own bot. In any
  other run (a pull request's, an unprotected branch's, a scheduled or
  triggered run, a merge queue's commit) the trigger job fails at once and
  its log says why; the push check and `branchd ci plan` say so too. A
  triggered run never triggers again.
- **`trigger:`** in a job starts a run of `pipeline` (the name of
  `.branchd/pipelines/<pipeline>.yaml` there) in `repo`, at `ref` (a branch;
  empty is its default branch), with `inputs`. With `wait: true` the job
  takes that run's result; without it, the job does not wait for that
  result.
- **The target opts in** with `on: trigger`, and `from:` says who may start
  it: `organisation` (anyone in it), `company` (repositories of teams the
  same company owns), or a list of repository paths. `from:` is read from
  the target's default branch, whatever `ref:` names. A repository
  triggering its own pipeline must list itself. A caller it does not allow is
  refused, and the refusal says nothing about the other repository.
- **Limits.** A run may start at most 20 triggered runs, and a repository
  takes at most 120 triggered runs an hour.
- **It runs as the target.** The other run uses the target repository's
  secrets, runners and job token, at the target's ref. That is the opposite
  of a [reusable pipeline](https://docs.branchd.run/branchd/pipelines/reusable-pipelines), whose
  jobs join your run, at your commit, with your secrets.
- **A trigger job runs nothing here**, so it takes only `trigger`, `needs`,
  `if`, `matrix`, `environment`, `concurrency`, `manual` and
  `continue-on-error`.
- In the target, `event == 'trigger'` is true in a triggered run, and inputs
  the caller does not give read their defaults.

## Calling a repository during its GitLab migration

A repository can keep its ordinary builds and deployments on GitLab while
accepting a specific pipeline call on branchd. Ask a branchd operator to
enable inbound triggers for the target repository. Commit the target
pipeline to its default branch and to each branch callers select with
`ref`.

Give that pipeline a single event, `on.trigger`, and list its callers in
`from`. For example, to adapt the target above, remove its `push` event
and set `from: [acme/web]` if `acme/web` is the caller. The default
branch controls admission even when the caller requests another branch.
The caller can keep the same `repo`, `pipeline`, and `ref` when you move
the build to branchd.

Source: https://docs.branchd.run/branchd/pipelines/trigger-another-repository
