workflow

on:

Declares the events that trigger the workflow. Accepts a single event, a list, or a map with per-event filters (branches, paths, tags, types).

on: <event> | [event1, event2] | { event: {filters} }

Common values / subkeys

Value / Subkey Purpose
push Trigger on pushes; filter with branches/paths/tags
pull_request Trigger on PR events; filter with types (opened, synchronize, closed)
workflow_dispatch Manual run with optional typed inputs
schedule Cron trigger (UTC only)
workflow_call Marks workflow as reusable/callable
workflow_run Trigger after another workflow completes

Examples

on: [push, pull_request]

Shorthand list of events, no filters

on:
  push:
    branches: [main]
    paths: ['src/**']

Push to main with path filter

on:
  schedule:
    - cron: '0 6 * * 1-5'

Weekdays at 06:00 UTC

on:
  workflow_dispatch:
    inputs:
      env:
        type: choice
        options: [dev, prod]

Manual trigger with typed input

Gotcha

Cron schedules run in UTC and may be delayed under load; scheduled workflows on inactive repos are auto-disabled after 60 days.

Related keywords

← All GitHub Actions syntax · Git commands · Cron syntax