# GitHub Actions — .github/workflows/ci.ymlname: CIon: [push, pull_request] # triggerjobs: test: # a job runs-on: ubuntu-latest # the runner steps: - uses: actions/checkout@v4 # reusable action - run: npm ci # build/install - run: npm test # test step
# GitLab CI — .gitlab-ci.ymlstages: [build, test, deploy] # ordered stagesunit-test: stage: test script: - npm ci - npm test needs: [build-job] # DAG dependency
You and friends build a giant LEGO castle together. Every time anyone adds a brick, a robot
instantly checks: does the castle still stand? does it look right? If yes, the robot photocopies
the castle and puts the copy on the display shelf. CI is the robot checking each new brick fast;
CD is the robot putting safe copies on the shelf. Doing tiny checks all the time means you never
discover at the end that the whole tower was crooked.
Socho 20 log ek hi codebase pe kaam kar rahe hain. Agar har koi apna change bina check kiye merge karega,
to bugs aur conflicts pile up ho jayenge aur end pe sab kuch toot jayega. CI (Continuous Integration)
ka idea simple hai: chhote-chhote changes baar-baar merge karo, aur har merge pe ek robot automatically
build + test chala de. Issse bug "type karte hi" pakda jata hai — jo fix karna sabse sasta hota hai.
Yeh "shift left" principle hai: failure ko time mein jitna left (early) le jao, utna better.
CD do flavour mein aata hai. Continuous Delivery matlab har passing build ka ek deployable
artifact ban jata hai, par production pe bhejne ke liye ek banda manually button dabata hai.
Continuous Deployment matlab woh button bhi automatic — seedha users tak. Yaad rakho:
Delivery mein ek aadmi abhi bhi "live" rehta hai button pe.
Pipeline stages ek order mein chalte hain: Source → Build → Lint → Test → Package → Deploy.
Cheap aur fast cheezein (lint) pehle, taaki agar woh fail ho to mehnga deploy chalाने ki zaroorat hi na pade.
GitHub Actions mein hierarchy hai Workflow → Job → Step, aur GitLab CI mein Pipeline → Stage → Job.
Ek stage ke andar ke jobs parallel chalte hain, aur stages aapas mein sequential.
Important baatein: secrets kabhi YAML mein mat likho (git history mein hamesha ke liye leak ho jata hai) —
platform ka secret store use karo. Aur "zyada runners = hamesha fast" galat hai: speedup tab tak hi badhta
hai jab tak runners ki sankhya independent jobs ke barabar (m = n) na ho jaye. Formula: parallel time
T=t⌈n/m⌉. Yeh sab samajh lo to CI/CD ka pura mental model clear ho jata hai.