Course contentsShow
← Cloud and Infrastructure
Lesson 1685 of 2,98935. GitHub ActionsFree lesson

Triggering Workflows with Events

Exploring event triggers including push, pull_request, schedule, and workflow_dispatch for automation.

Triggering Workflows with Events

You'll learn how to automatically start GitHub Actions workflows using different event types that respond to repository activity and schedules.

What Are Workflow Events?

In GitHub Actions, workflows don't run magically—they need a trigger. Events are the signals that tell GitHub "start this workflow now." Think of events like alarm clocks: some go off when you press a button, others ring at scheduled times, and some activate when specific conditions occur.

Core Event Triggers

push

Triggers when code is pushed to specified branches. This is your most common trigger—perfect for running tests whenever someone commits changes.

on:
  push:
    branches: [main, develop]

pull_request

Fires when pull requests are opened, updated, or synchronized. Ideal for validation before merging.

on:
  pull_request:
    branches: [main]

schedule

Runs workflows at specific times using cron syntax—great for nightly builds or periodic cleanup tasks.

on:
  schedule:
    - cron: '0 2 * * *'  # 2 AM daily

workflow_dispatch

Enables manual workflow triggering through the GitHub UI—like a "run now" button for on-demand automation.

on:
  workflow_dispatch:

Combining Events

You can specify multiple triggers in one workflow, giving flexibility for different automation scenarios:

on:
  push:
    branches: [main]
  pull_request:
  schedule:
    - cron: '0 0 * * 0'  # Weekly
  workflow_dispatch:

Key Takeaway: GitHub Actions workflows rely on event triggers—push for code changes, pull_request for PR validation, schedule for time-based automation, and workflow_dispatch for manual control—enabling flexible, automated CI/CD responses to repository activity.