Script Valley
CI/CD with GitHub Actions
GitHub Actions FundamentalsLesson 1.3

How GitHub Actions triggers and events work

push event, pull_request event, workflow_dispatch, schedule cron, event filters, branch filtering, path filtering

The on Block Controls Everything

GitHub Actions trigger types

The on block determines when your workflow runs. Choosing the right trigger prevents unnecessary runs and keeps your free tier usage low.

Common Triggers

on:
  push:
    branches: [main, develop]
    paths:
      - 'src/**'
  pull_request:
    branches: [main]
  schedule:
    - cron: '0 6 * * 1'   # Every Monday at 06:00 UTC
  workflow_dispatch:       # Manual trigger from GitHub UI

push โ€” fires when commits are pushed. Add branches to limit scope. Add paths to only trigger when specific files change โ€” useful for monorepos.

pull_request โ€” fires when a PR is opened, updated, or synchronized. Ideal for running tests on proposed changes before merge.

schedule โ€” uses standard cron syntax. Useful for nightly builds, dependency audits, or cleanup jobs.

workflow_dispatch โ€” adds a manual trigger button in the GitHub UI. You can define inputs to parameterize the run.

Combining Triggers

A single workflow can listen to multiple events simultaneously. List them as sibling keys under on. Each event can have its own filters. The workflow runs once per matching event regardless of how many are listed.

Up next

What are GitHub Actions runners and how to choose one

Sign in to track progress

How GitHub Actions triggers and events work โ€” GitHub Actions Fundamentals โ€” CI/CD with GitHub Actions โ€” Script Valley โ€” Script Valley