Pipeline Anatomy: Triggers, Jobs, Cache, Artifacts
How a CI/CD pipeline turns a git push into parallel jobs, cached dependencies, build artifacts, and a deployment gate.
TL;DR
A CI/CD pipeline is an event-driven DAG: a trigger (push, pull_request) spawns jobs on clean runners, caches restore unchanged dependencies, artifacts carry build outputs across stages, and a deploy gate promotes only verified builds.
Intent
Understand the five building blocks of every modern CI/CD pipeline—triggers, parallel jobs, caching, artifacts, and deploy gates—using this repository's own .github/workflows/ci.yml as a concrete reference.
Problem
Treating CI as one opaque bash script makes builds slow and brittle. Installing packages from scratch on every commit wastes minutes, running lint/test/build sequentially delays feedback, and deploying without a gate lets broken commits reach users.
Solution
Every healthy pipeline separates five responsibilities:
- Trigger (
on:): Declarative rules (pushtomain,pull_request) decide when the workflow starts. - Parallel Jobs (
jobs:): Independent checks (lint, typecheck, unit tests, build) run concurrently on separate runners unless linked byneeds:. - Cache Restore / Save: Package stores (like
pnpmstore keyed bypnpm-lock.yaml) are restored beforepnpm install --frozen-lockfileand saved afterward. - Artifacts: Build outputs (
out/), Playwright traces, or coverage reports are uploaded so downstream jobs or reviewers can inspect or deploy them. - Deploy Gate: Branch protection and environment rules require all check jobs to succeed before the deploy step runs.
Real-world analogy
▶ Flow: watch it work
CI/CD Pipeline: Trigger → Cache → Jobs → Artifacts → Gate
Press Start or tap any step dot to trace the path.
▸All steps (5)
Code
Here is the real .github/workflows/ci.yml from this repository:
name: CI
on:
push:
branches: [main, mengtylearns-mvp]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 11.6.0
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm typecheck
- run: pnpm buildWhen to use / when to avoid
- You want fast feedback by running independent checks (lint, unit tests, build) in parallel.
- You need reproducible builds using --frozen-lockfile and cached dependency stores.
- Splitting a 20-second workflow into 6 tiny jobs where runner boot + checkout overhead exceeds the work saved.
- Storing secrets inside caches or artifacts—both are accessible to workflow runs and should never hold credentials.
How to implement
Define narrow triggers
Trigger on pull_request and pushes to main so every merge candidate is checked.
Cache dependencies by lockfile hash
Use actions/setup-node with cache: pnpm and pnpm install --frozen-lockfile.
Gate deployment on check jobs
Require lint, typecheck, test, and build to pass before deploying artifacts.
Pros / Cons
- Parallel jobs cut wall-clock feedback time for developers.
- Immutable artifacts guarantee you deploy the exact bits that passed tests.
- Cache misses or oversized artifacts can still slow runners down if not scoped carefully.
- Runner startup overhead means very small scripts can be faster in one combined job.
Relations
Check yourself
Check Yourself
1. Why does .github/workflows/ci.yml pass --frozen-lockfile to pnpm install?
2. When should you use a GitHub Actions artifact instead of a cache?
Sources
Related Notes
GitHub Actions Workflow
How to write a minimal, supply-chain-safe GitHub Actions CI workflow with SHA-pinned actions and deterministic installs.
Caching That Actually Works in CI/CD
Speed up GitHub Actions with pnpm store caching and Docker layer caching (cache-from/to gha), design stable cache keys, and know when caching hurts.