A beginner-friendly guide to understanding when your workflows run

What is the on: Section?

Think of the on: section as the doorbell for your workflow. It tells GitHub Actions: "Hey, when THIS happens, please run my workflow!"

name: My Workflow
on:
  push:# This is the trigger - when someone pushes codebranches: [ main ]
jobs:
# Your workflow jobs go here...

Why do we need it?

Think of it like setting up notifications on your phone - you choose what events are important enough to alert you!

🎯 Common Trigger Types

1. push - When Code is Uploaded

What it does: Runs your workflow whenever someone pushes (uploads) code to your repository.

on:
  push:
    branches: [ main ]# Only when pushing to main branch

Real-world example:

More push examples:

on:
  push:
    branches: [ main, develop ]# Multiple branches

# Or trigger on any branchon:
  push:# No branches specified = all branches

2. pull_request - When Someone Suggests Changes