# A manual pipeline with inputs

> Let a person start a pipeline by hand, with typed inputs that the jobs read.
> **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).

```yaml title=".branchd/pipelines/release.yaml"
# .branchd/pipelines/release.yaml
# Started by hand, with typed inputs. On any other event an input reads its
# default, so the if: below works everywhere.
name: Release
on:
  manual:
    inputs:
      version:
        type: string
        required: true
        description: The version to tag, such as 1.4.0.
      channel:
        type: choice
        options: [stable, beta]
        default: beta
      dry_run:
        type: boolean
        default: true
jobs:
  release:
    image: alpine/git:2.47
    env:
      CHANNEL: ${{ inputs.channel }}
    steps:
      - run: echo "releasing ${{ inputs.version }} to $CHANNEL"
      - if: ${{ !inputs.dry_run }}
        run: ./scripts/tag-release.sh "${{ inputs.version }}"
```

- **`on: manual`** lets a person start this pipeline. `inputs:` declares what
  they give, each with a `type`: `string` (the default), `boolean`,
  `number` or `choice` (which needs `options`). `default`, `required` and
  `description` are optional.
- **Checked before the run starts.** A value of the wrong type, a `choice`
  outside its options, an input the file does not declare, or a missing
  required input with no default refuses the run.
- **`${{ inputs.<name> }}`** reads one, in `if:`, `env:`, `run:` and
  `with:`. In a `run:` it is a variable, never shell text.
- **On every other event** an input reads its default, else `''`, `false` or
  `0`, so an `if:` that reads one works for every event the file has.
- An input declared under both `manual` and `trigger` must have one type.

## Start it

From a terminal, inside the clone (a run of `main`'s current commit):

```bash
branchd run start main --pipeline Release --input version=1.4.0 --input channel=stable --input dry_run=false
```

From a job or a script, with the API (a job needs `permissions: {pipelines: write}`, see [The job token](https://docs.branchd.run/branchd/pipelines/job-token)):

```bash
curl -fsS -H "Authorization: Bearer $BRANCHD_TOKEN" -H 'Content-Type: application/json' \
  "$BRANCHD_API_URL/xeonr.forge.v1.RunService/CreateRun" \
  -d '{"repository":"acme/app","ref":"main","pipeline":"Release","inputs":{"version":"1.4.0","channel":"stable","dry_run":"false"}}'
```

`--pipeline` is the pipeline's `name:` (else its file name without
`.yaml`); its `on:` must list `manual`. Inputs are sent as text and checked
against their types: a refusal exits 2 and says which input and why.

To see what it would run first:

```bash
branchd ci plan --event manual --pipeline Release --input version=1.4.0
```

> **Not yet available** (cli 0.39.0): `branchd run start --pipeline … --input …` is in the next CLI release; until then use the API form above.

> **Not yet available** (console): the console's **Run pipeline** starts a run of a branch only, with no pipeline or inputs to choose.

Source: https://docs.branchd.run/branchd/pipelines/manual-runs
