03Deep Dive

Workflows In Detail

The workflow is the "Brain" of your automation. It's a YAML file that coordinates exactly what happens, when, and where.

1. Anatomy of a Workflow

Hover over keys to explore
name: My Awesome Workflow
on: push:
jobs: build-and-test:
runs-on: ubuntu-latest
steps
- name: Checkout code
uses: actions/checkout@v4
- name: Install deps
run: npm install

Hover over the YAML keys to see what each part does.

2. Common Triggers (on)

Event-Based

Runs when something happens in GitHub.

pushpull_requestfork

Scheduled

Runs at specific times using cron syntax.

cron: "0 0 * * *"Daily Builds

Manual

Triggered by a human from the UI.

workflow_dispatchrepository_dispatch

3. Job Dependencies (needs)

By default, jobs run in parallel. Use `needs` to create a sequential pipeline.

Build
Test
Deploy

Workflow Pro-Tips

Use Env Variables

"Don't hardcode sensitive values. Use GitHub Secrets and environment variables for flexibility."

Conditional Execution

"Use the `if` conditional to skip jobs or steps based on branch names or event types."