on

1 minute read

Use on to define a triggering event that runs the workflow. Currently there are two repository triggers, push and pull-request, that cause a workflow to execute.

Example usage

In the following example, a workflow runs in response to a pull request event to the main branch of a repository.

on:
  pull-request:
    branches:
      - 'main'

In the following example, a workflow runs in response to a push event to either a repository demo branch or to any file in its test directory.

on:
  push:
    branches:
      - 'demo'
      - 'test/**'

The * wildcard matches any character, but does not match /. The ** matches any character, including /.

Definition of a triggering event

The table below defines when a push event results in a workflow run:

Table 1. Push events to a branch and resulting workflow
on.push.branches input Push to repository branch Workflow result

'test/*'

'test/foo'

Runs

'test/*'

'test/foo/bar'

Does not run

'test/*/bar'

'test/foo/bar'

Runs

'test/**'

'test/foo'

Runs

'test/**'

'test/foo/bar'

Runs

'**'

Any branch

Runs