# Environments and manual approval

> Record deployments to named environments, and hold a job until a person releases it.
> **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/ci.yaml"
# .branchd/pipelines/ci.yaml
# Deploy to production only after a person releases the job. It waits up
# to a day, then is skipped; the run is not held open for it.
name: CI
on:
  push:
    branches: [main]
jobs:
  test:
    image: golang:1.26
    steps:
      - run: go test ./...
  deploy-stage:
    needs: [test]
    image: alpine:3
    environment: {name: stage, url: 'https://stage.app.example.com'}
    secrets: [DEPLOY_TOKEN]
    steps:
      - run: ./scripts/deploy.sh stage
  deploy-production:
    needs: [deploy-stage]
    image: alpine:3
    environment: {name: production, url: 'https://app.example.com'}
    concurrency: {group: production}
    manual:
      wait: 24h
      on-expiry: skip
      blocking: false
    secrets: [DEPLOY_TOKEN]
    steps:
      - run: ./scripts/deploy.sh production
```

- **`environment:`** is a name, or `{name, url}`. Each run of the job records
  a deployment to it.
- **`manual:`** holds the job until a person releases it. `manual: true`
  waits without limit. The long form is `{wait, on-expiry, blocking}`: `wait`
  how long to wait (`24h`), `on-expiry` what happens then (`fail` or `skip`),
  and `blocking: false` lets the rest of the run finish while it waits.
- **Releasing.** On the run's page in the browser, or
  `branchd run release <run> <job>`. Who may release is set by the branch's
  rules: on a protected branch, one of the rule's merge roles, and only a
  person (or an agent acting for one, which counts as that person) when the
  rule asks for a person's approval; never a bot or a job.
- **`concurrency: {group: production}`** keeps two production deploys from
  overlapping.

`if:` cannot ask a person: it is decided when the run is compiled. Use
`manual:` for a decision made while the run is going.

Source: https://docs.branchd.run/branchd/pipelines/environments-and-approval
