A beginner-friendly guide to understanding when your workflows run
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!
push - When Code is UploadedWhat 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
pull_request - When Someone Suggests Changes