# Triggers
Source: https://docs.infraista.com/en/developer-tools/pipelines/triggers



The `on:` block of the pipeline file decides when a pipeline runs. You can edit it in the file or on
the pipeline's **Triggers** tab, which writes the same keys and saves them as a commit or a pull
request.

```yaml
on:
  push:
    branches: [main, release/*]
    paths-ignore: [docs/**]
  pull_request:
    branches: [main]
    drafts: false
  tags: [v*]
  schedule:
    - cron: "0 2 * * *"         # UTC
      branch: main
  manual: true
  webhook: true
  pipeline_completed:
    - pipeline: infrastructure
      when: success
```

Without `on:`, a pipeline only runs by hand.

## Push [#push]

Runs when commits are pushed to matching branches.

| Option            | Meaning                                                              |
| ----------------- | -------------------------------------------------------------------- |
| `branches`        | Branches to run on. Globs work: `release/*`, or `*` for every branch |
| `branches-ignore` | Branches to leave out                                                |
| `paths`           | Run only when the push touches these paths                           |
| `paths-ignore`    | Don't run when the push only touches these paths                     |

## Pull requests [#pull-requests]

Runs on pull requests (merge requests on GitLab) opened or updated against the target `branches`, and
reports the result on the pull request. Also takes `paths` and `paths-ignore`. With `drafts: false`
(the default), draft pull requests start a run when they're marked ready for review.

Pull requests from forks get only the secrets marked for forks, can't use self-hosted runners and
never deploy to protected environments.

## Tags [#tags]

`tags: [v*]` runs when a matching tag is pushed: `v*` matches `v1.4.0` and `v2.0.0-rc.1`. `tags: true`
runs on every tag.

## Schedule [#schedule]

Each `cron` has 5 fields and runs in **UTC** on the latest commit of `branch` (the default branch when
left out). `0 2 * * *` is every day at 02:00 UTC.

## Manual runs and inputs [#manual-runs-and-inputs]

`manual: true` lets people who can run pipelines start it with **Run pipeline**. Inputs in the file
appear as a form and reach jobs as `$inputs.NAME`; see
[inputs](/en/developer-tools/pipelines/pipeline-file-reference#inputs).

## Webhook (API trigger) [#webhook-api-trigger]

`webhook: true` lets another system start a run with an HTTP request. On the **Triggers** tab, create
the webhook token (it's shown once; regenerating it stops the old one at once). The token only starts
this pipeline: it can't read logs or secrets.

```bash
curl -X POST https://api.infraista.com/api/pipelines/hooks/PIPELINE_ID \
  -H "Authorization: Bearer iph_..." \
  -H "Content-Type: application/json" \
  -d '{"branch": "main", "inputs": {"target": "staging"}}'
```

It answers `201` with the run number and its URL. `branch` and `inputs` are optional, and the file on
that branch must list `webhook`. Up to 30 requests a minute.

## When another pipeline finishes [#when-another-pipeline-finishes]

`pipeline_completed` starts this pipeline, on the head of its default branch, when a run of another
pipeline in the organization ends:

* `pipeline`: the other pipeline's name;
* `when`: `success`, `failure` or `completed`;
* `branches` (optional): only for runs of these branches.

Chains stop after 3 pipelines.

## Skipping a run [#skipping-a-run]

A commit whose message contains `[skip ci]`, `[ci skip]`, `[no ci]` or `[skip pipelines]` doesn't
start push or pull request runs. Scheduled, manual, webhook and pipeline-completion runs still start.
To ignore the markers, turn the option off in the pipeline's **Settings**.

## Related [#related]

* [Runs and logs](/en/developer-tools/pipelines/runs-and-logs)
* [Pipeline file reference](/en/developer-tools/pipelines/pipeline-file-reference)
