devops · ci-cd CI/CD pipeline, push to production How a commit travels through build, test, scan and deploy with GitHub Actions, Docker and Kubernetes. Build compile, image → Test unit, integration → Scan deps, image, secrets → Deploy roll out safely my-service/ .github/ workflows/ ci-cd.yml the pipeline src/ Dockerfile how to package it k8s/ deployment.yml how to run it .github/workflows/ci-cd.yml 1on:2 push:3 branches: [main]4jobs:5 test:6 runs-on: ubuntu-latest7 steps:8 - uses: actions/checkout@v49 - run: npm ci && npm test10 deploy:11 needs: test12 runs-on: ubuntu-latest Dockerfile 1FROM node:24-slim AS build2WORKDIR /app3COPY package*.json ./4RUN npm ci5COPY . .6RUN npm run build7 8FROM node:24-slim9WORKDIR /app10COPY --from=build /app/dist ./dist11USER node12CMD ["node", "dist/server.js"] Rolling update default • Replaces pods a few at a time • No extra environment needed • Old and new run side by side briefly Blue-green • Two full environments • Switch traffic in one step • Instant rollback, double the capacity Canary • Send a small share of traffic first • Watch errors, then widen • Needs traffic splitting and good metrics ✓ Secrets live in the CI secret store, never in the repo ✓ Scan dependencies and the image before deploying ✓ Pin action and base-image versions ✓ Add readiness probes so bad pods never get traffic ✓ Know how to roll back before you need to Tip Build once, promote the same image through every environment. Every push starts the same four-stage road. A failure at any stage stops the line. Keep the pipeline definition in the repository, next to the code it builds. A workflow is triggers plus jobs. Build and test run first; later jobs wait with needs. Package once. The same image is tested, scanned and deployed, so what you tested is what ships. Three ways to roll out a new version. Pick by how much risk and spare capacity you have. Before you call the pipeline done, check the habits that keep it safe and calm. Deploy the artifact you tested. Never rebuild it for production. ← Pause → Cheatsheet The pipeline Stage Question it answers Typical tools Build Does it compile and package? docker build, npm run build Test Does it behave correctly? unit and integration tests Scan Is it safe to ship? dependency, image and secret scanners Deploy Can users get it without downtime? kubectl, Helm, Argo CD Rollout strategies Rolling update: replace pods gradually. The Kubernetes default. Blue-green: run old and new side by side, switch traffic at once. Canary: send a small share of traffic to the new version first. Commands you will use bash Copy kubectl rollout status deployment/my-service kubectl rollout undo deployment/my-service kubectl set image deployment/my-service app=registry/app:1.4.2 Safety habits Keep secrets in the CI secret store. Pin versions of actions and base images. Build once, promote the same image everywhere. Add readiness probes and know your rollback command.