CI/CD Pipelines
Automating build-test-deploy: artifacts built once, environments promoted, gates that never forget.
Before this: Testing Your App
Objective
Automate the road from commit to production: a pipeline running quality gates on every push, building ONE artifact promoted across environments, deployment gates that block bad releases, and secrets handled correctly.
Vocabulary
The words to use when directing your agent.
- pipeline
- The automated sequence from code change to deployed software.
- artifact
- The built, versioned output of one pipeline run - what actually deploys.
- staging
- A pre-production environment configured like production for final verification.
- promotion
- Moving the SAME artifact forward: staging, then production.
- deployment gate
- An automated check that must pass before deployment continues.
Understand it
Pipeline anatomy
Push triggers the pipeline: install dependencies from lockfile, lint and typecheck, run the test suite, validate curriculum data, build the artifact once. Green artifact deploys to staging automatically; promotion to production follows the same artifact after gates pass. Secrets enter the pipeline through the CI platform's encrypted settings - referenced by name in workflow files, values never present in code.
Fast feedback is a feature
A pipeline taking hours teaches people to stop waiting. Keep the main gate fast enough to run on every push: fail on the first broken stage, parallelize independent stages, keep suites lean. Slow pipelines get bypassed psychologically long before anyone dares bypass them technically.
Core concepts
Build once, promote everywhere
The artifact that passed staging IS the artifact production receives. Rebuilding per environment means deploying something nobody tested - configuration drift wearing a lab coat. Environment differences belong in environment variables injected at deploy time, not recompiled into new binaries.
Gates outperform memory
Humans forget to run tests under deadline pressure; pipelines never do. Typecheck, tests, curriculum validation, build - automated on every push, blocking merges when red. The gate converts your team's standards from documentation into physics.
Examples
Red means stop
A commit breaks one test. Pipeline flags red; merge blocked; deploy never runs. The bug died in CI instead of in front of users - which is the entire business case for the twenty minutes spent writing the workflow file.
Preview deployments
Many platforms spin a temporary live URL per branch or pull request. Reviewers click reality instead of imagining it. Your curriculum site can demo every change before it lands on main - gates plus previews make review concrete.
Common mistakes
Common mistake
Committing secrets into workflow files or build scripts because 'CI needed the key'.
Fix
Secrets go in the CI platform's encrypted variable store, referenced by name. Workflow files stay committable and clean - audit them like code because they ARE code with production power.
Common mistake
Treating flaky red builds as normal, rerunning until green.
Fix
A flaky gate trains everyone to ignore the gate. Fix or quarantine flaky tests immediately - a red everyone ignores is worse than no gate.
Working with your AI agent
Have your agent author the pipeline definition, then EXPLAIN every stage: what it installs, what command runs, what blocks progression. You review the explanation before merging - pipeline files are production code with deploy powers, deserving the same review rigor as authentication changes.
Build it
The module’s real project. Your agent builds; you direct and inspect.
Project: Pipeline Gate
Build the Ledger's automated railway: every push runs install, typecheck, tests and build; one artifact flows to staging-like preview with green-gate promotion to production; secrets stay platform-managed - and you deliberately break a test to watch the gate save you.
Requirements
- Every push triggers: lockfile-faithful install, lint/typecheck, full test suite, build
- Single artifact built per run and deployed onward - staging and production serve the same artifact
- Production promotion gated on green stages - red pipeline physically cannot reach production
- Secrets referenced by name from CI platform settings; zero secret values in repo files
- Deliberate break: sabotage a test, capture the blocked merge/deploy evidence, restore green
- Workflow file reviewed line by line with your agent explaining each stage's purpose
Context for your agent
Create a CI/CD pipeline for my Expense Ledger on my git host's CI platform. Stages: install from lockfile, lint + typecheck, test suite, build artifact once. Artifact auto-deploys to a staging/preview environment; production promotion uses the same artifact and requires green stages. Secrets referenced by encrypted platform variables only. Walk me through the finished workflow file line by line - I approve understanding, not just existence. Then coach my deliberate-break exercise: sabotage, observe the block, document, restore.
Verify it - twice
Check every item yourself first. Then hand your agent the prompt and compare verdicts.
Verification prompt - paste into your AI agent
Audit my Pipeline Gate as a release engineer reviewing someone's deploy automation for the first time. Verify PASS or FAIL with evidence: (1) trace one commit through every stage - did each gate genuinely run, or skip quietly?, (2) confirm the artifact reaching production is the one staging verified - how is provenance visible?, (3) attempt to argue a bypass: which shortcut would a rushed teammate take, and does the pipeline prevent it?, (4) inspect the workflow file for secret exposure and shell-injection risks from untrusted input. Finish with the two weakest links in my pipeline and the cheapest fix for each.
Run this against “CI/CD Pipelines” after your own checklist pass. Where the agent and you disagree, investigate before moving on.
Review questions
Answer out loud. If you cannot, revisit before moving on.
Why does rebuilding per environment defeat the point of staging?
Which gate saved YOU during the break exercise - and what would have happened without it?
Where do your pipeline's secrets live, and who can read them?
You can now
- Automate quality gates that outrank human memory
- Promote one immutable artifact across environments
- Handle CI secrets and workflow files with production-code discipline
Up next
Failure Handling