What is CI/CD — DevOps

CI/CD is an automated pipeline (path) that takes code from push to production. CI (Continuous Integration): every push automatically gets its dependencies…

One small change is deployed late in the afternoon, and you go home. Ten minutes later, everyone who opens the notes list gets a 500 error (the server failed to answer). The tests would have caught the bug in nine seconds. The trouble is, nobody ran them.

CI/CD is the automated path that takes your code from git push to running in production. The code is fetched, its dependencies are installed, then it is checked, packaged and shipped, in the same order every time. Picture a catering kitchen. Every new recipe gets tasted first, then packed, then sent to the customer. A dish that fails the tasting is never packed, and never sent. In CI/CD, the new recipe is your code change, tasting is running the tests, packing is building the image, and sending is deploying to production. If the courier waits for the head chef's signature before leaving, that's Continuous Delivery: the deploy to production waits for a human's approval. If the courier leaves as soon as the package is ready, that's Continuous Deployment: the deploy runs by itself.

Manual deploys: the way we've done it so far

Until now, deploying notes-api was done by hand. You build the image on your laptop and push it to the registry. Then you log in to web-1 over SSH and run Compose with the new tag:

docker build -t ghcr.io/budi/notes-api:7d03b5f .
docker push ghcr.io/budi/notes-api:7d03b5f
ssh deploy@web-1 "cd /srv/notes-api && IMAGE_TAG=7d03b5f docker compose up -d"

The tag 7d03b5f is the Git commit's code, and IMAGE_TAG=7d03b5f tells Compose which image tag to run. The steps are right, but nothing forces the tests to run first. In commit 7d03b5f ("show the newest notes first"), the table name is mistyped as nots, and on your laptop you forgot to run npm test. After the deploy, every GET /notes request in production gets a 500 error, and the app log says:

2026-10-09 10:15:02 ERROR relation "nots" does not exist

That's the trouble with manual deploys. A step can be skipped, everyone may do it differently, and a bug is only found after people using the app hit it.

CI: every push is checked automatically

Continuous Integration (CI) means every push (or pull request, a request to merge a branch into main) makes a CI server fetch the code. The CI server then runs the same checks every time: install the dependencies, lint (check the code for style and common mistakes), then test. The result is a green mark (passed) or a red one (failed) on that commit. It's called "integration" because the aim is to merge everyone's code into main as often as possible. Merging that often is safe because a machine checks every merge.

CD: what passes gets shipped

Once CI is green, the remaining stages package and ship the code: build the image, push it to the registry, then deploy to web-1. The D in CD has two meanings:

Continuous Delivery Continuous Deployment
Automated up to ready to deploy, one click left production
Deploying to production waits for a human's approval happens right away, no click
Fits teams that want to pick the release time teams with strong tests

There's only one difference: whether there's an approval button before production.

The notes-api pipeline

That chain of stages from push to deploy is called a pipeline, and each stage is called a step. This is notes-api's pipeline in the Lab, five steps in order:

# Step name Command Category
1 Install dependencies npm ci build
2 Run ESLint npm run lint lint
3 Run unit tests npm test test
4 Build Docker image docker build then docker push build
5 Deploy to web-1 IMAGE_TAG=... docker compose up -d over SSH deploy

The Category column (also used in the exercise) comes from keywords in the step name. Upper and lower case count as the same. The rules are checked in a fixed order, and the first rule that matches sets the category:

  1. contains "build", "compile" or "install": build
  2. contains "lint", "format" or "style": lint
  3. contains "test", "spec" or "coverage": test
  4. contains "deploy", "release" or "publish": deploy
  5. anything else: other, for example "Send Slack notification"

The order matters. "Build and test" contains both "build" and "test", but the build rule is checked first, so its category is build. "Run ESLint" is lint, because "eslint" contains "lint".

One step fails, the rest stop

Two commits are pushed one after the other, and each one goes through the pipeline with Continuous Deployment:

Step a41c9e2 add note search 7d03b5f newest notes first
Install dependencies passed, 18 seconds passed, 18 seconds
Run ESLint passed, 6 seconds passed, 6 seconds
Run unit tests passed, 11 seconds failed, 9 seconds
Build Docker image passed, 42 seconds skipped
Deploy to web-1 passed, 15 seconds skipped
Production on web-1 becomes a41c9e2 stays a41c9e2

Once a step fails, the steps after it don't run. The image for 7d03b5f is never built, so it is never shipped. People using the app keep the healthy a41c9e2. The one who gets the red result is you, not them. This is an excerpt of the test step's log on GitHub Actions:

 FAIL  test/notes.test.js > GET /notes > returns the list of notes
AssertionError: expected 500 to be 200 // Object.is equality

- Expected
+ Received

- 200
+ 500

 Test Files  1 failed | 2 passed (3)
      Tests  1 failed | 11 passed (12)
Error: Process completed with exit code 1.

The test for GET /notes expected the status 200 (success) but received 500, and exit code 1 makes the step fail. Fix the typo, push again, and the same pipeline carries the fix to production.

The tools

Popular choices: GitHub Actions (built into GitHub, covered in the next lesson), GitLab CI, Jenkins and CircleCI. They all read the pipeline's settings from a file in the repo, so your pipeline gets reviewed (checked by the team) like code. The Testing in a CI/CD Pipeline lesson (Testing track) covers the order of lint, tests and E2E tests (tests that try the app from end to end), and also branch protection (rules that protect main). Keeping deploy secrets safe in a pipeline is covered in the CI/CD Pipeline Security lesson (Security track).

⚠️ A pipeline that exists but doesn't really guard

TL;DR: CI/CD is an automated pipeline (path) that takes code from push to production. CI (Continuous Integration): every push automatically gets its dependencies installed, is linted (checked for style and common mistakes) and is tested, and the result is green (passed) or red (failed). CD has two meanings: Continuous Delivery (ready to deploy, but the deploy to production waits for a human's approval) and Continuous Deployment (code that passes every check goes right to production). notes-api's pipeline has five steps (stages): install, lint, test, build the image, deploy to the web-1 server. Once a step fails, the remaining steps are skipped, so code with red tests never reaches the people using the app. A step's category comes from keywords in its name, checked in a fixed order: build, lint, test, deploy, otherwise other. Popular tools: GitHub Actions, GitLab CI, Jenkins, CircleCI.

⚡ A manual deploy can skip the tests

Write:

docker build -t ghcr.io/budi/notes-api:7d03b5f .
docker push ghcr.io/budi/notes-api:7d03b5f
ssh deploy@web-1 "cd /srv/notes-api && IMAGE_TAG=7d03b5f docker compose up -d"

Meaning: This is a manual deploy: build the image on your laptop, push it to the registry, then run Compose on the web-1 server over SSH. The steps are right, but nothing forces the tests to run first. If you forget npm test and commit 7d03b5f has a mistyped table name, the bug is only found after people using the app get a 500 error (the server failed to answer).

⚡ CI: every push is checked automatically

Write:

npm ci
npm run lint
npm test

Meaning: Continuous Integration (CI): every push makes a CI server fetch the code and run the same checks. Here there are three: npm ci installs the dependencies, npm run lint checks the code for style and common mistakes, and npm test runs the tests. The result is a green mark (passed) or a red one (failed) on that commit.

⚡ CD: what passes gets shipped

Write:

Continuous Delivery     ready to deploy, production waits for approval
Continuous Deployment   production straight away, no click
Guess first: both are called CD. What is the only difference?

Whether there's an approval button before production. Delivery waits for a human to approve, Deployment goes ahead as soon as every check passes.

Meaning: CD ships the code that passed CI to production: build the image, push it to the registry, then deploy. CI/CD = Continuous Integration / Continuous Deployment (or Delivery): the automated path from push to production.

⚡ One step fails, the rest stop

Write:

Run unit tests       failed, 9 seconds
Build Docker image   skipped
Deploy to web-1      skipped

Meaning: Each stage of the pipeline (the CI/CD path) is called a step. Once a step fails, the steps after it are skipped. So the image for a commit with red tests is never built, and never shipped. People using the app keep the old, healthy version, and the one who gets the red result is you, not them.

What you will learn