Episode 2 β Core Concepts: Workflows, Jobs, Steps & Actions
In Episode 1, we understood what CI/CD is and where GitHub Actions fits.
Now itβs time to understand the core building blocks of GitHub Actions.
Most confusion around GitHub Actions comes from not having a clear mental model of:
- workflows
- jobs
- steps
- actions
Once these click, everything else becomes easier.
The Big Picture (Mental Model)
Think of GitHub Actions like this:
Workflow
βββ Job(s)
βββ Step(s)
βββ run (your command)
βββ uses (reusable action)
Letβs break this down one by one.
1οΈβ£ What is a Workflow?
A workflow is the top-level automation.
It:
- lives inside your repository
- is written in YAML
- defines when and what should run
π Location:
.github/workflows/ci.yml
Example:
name: CI Pipeline
on: push
This means:
βRun this pipeline when code is pushedβ
2οΈβ£ What is a Job?
A job is a logical stage inside a workflow.
Each job:
- runs on a machine (runner)
- has its own environment
- contains steps
- runs in parallel by default
Example:
jobs:
build:
runs-on: ubuntu-latest
Here:
-
buildis the job name -
ubuntu-latestis the runner (machine)
3οΈβ£ What is a Step?
A step is a single task inside a job.
Steps:
- run in order
- share the same machine
- can access files created by previous steps
Example:
steps:
- run: npm install
- run: npm test
Each run is a step.
4οΈβ£ What is an Action?
An action is a reusable block of logic written by GitHub or the community.
Instead of writing everything yourself, you reuse actions.
Example:
- uses: actions/checkout@v4
This action:
- clones your repository into the runner
- handles authentication
- works for private repos
- supports PRs, branches, and commits
Without it, your runner has no code.
5οΈβ£ run vs uses (Very Important)
run
- Executes shell commands
- You write the logic
- run: npm ci
uses
- Executes reusable logic
- Someone else wrote the code
- uses: actions/setup-node@v4
π Rule of thumb:
- Project-specific logic β
run - Reusable setup logic β
uses
6οΈβ£ A Complete Example (Everything Together)
name: CI
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
- run: npm test
Whatβs happening here:
- Workflow runs on PR
- One job (
test) - Runs on Ubuntu
- Uses actions to checkout code & setup Node
- Runs project commands
This is a clean CI pipeline.
7οΈβ£ Common Beginner Mistakes
β Forgetting actions/checkout
β Mixing CI & deployment logic
β Writing huge bash scripts inside workflows
β Not naming steps clearly
Good workflows are:
- readable
- predictable
- boring (in a good way)
Final Mental Model (Lock This In)
Workflow β automation
Job β stage
Step β task
Action β reusable logic
Runner β machine
If this model is clear, GitHub Actions will stop feeling magical and start feeling logical.
Whatβs Next?
π Episode 3:
Workflow Syntax & Events β push, pull_request, cron & manual triggers
Weβll finally answer:
- when does a workflow run?
- how to control it precisely?
Follow along if youβre learning GitHub Actions step by step π
Thanks for reading!
See you in the next episode π
Top comments (0)