CurriculumTeam WorkflowsCI/CD with GitHub Actions
Lesson 4 of 580%
Advanced12 min+120 XP

CI/CD with GitHub Actions

CI/CD stands for Continuous Integration and Continuous Deployment. CI automatically tests every code push. CD automatically deploys code that passes tests. Together they let teams ship safely multiple times per day with full confidence.

01.Continuous Integration (CI) in Practice

Every push to any branch and every PR triggers the CI pipeline. A typical pipeline: checkout → install deps → lint (catch code style issues) → unit tests → integration tests → build → code coverage check. If any step fails, the whole job fails, PRs are blocked from merging, and the author is notified. CI ensures main is always working code.

Commit Timeline
a1b2c3d
init
b2c3d4e
feat
c3d4e5f
fix
d4e5f6a
HEAD

02.Continuous Deployment (CD) in Practice

CD runs only after CI passes on main. Typical steps: run full test suite → build Docker image or static bundle → push image to registry → update staging environment automatically → run smoke tests against staging → if all pass, deploy to production. With good test coverage, teams deploy dozens of times per day with zero manual steps.

Distributed Architecture
💻
Your Local
push / pull
☁️
GitHub (Remote)
push / pull
💻
Teammate's Local

Commands

commands — click to reveal output
$
mkdir -p .github/workflows
Create the GitHub Actions workflows directory
$
# .github/workflows/ci-cd.yml # name: CI/CD Pipeline # on: # push: # branches: [main] # pull_request: # branches: [main] # jobs: # test: # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 # - uses: actions/setup-node@v4 # with: { node-version: '20' } # - run: npm ci # - run: npm run lint # - run: npm test # deploy: # needs: test # if: github.ref == 'refs/heads/main' # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 # - run: npm ci && npm run build # - run: npx gh-pages -d dist
Full CI/CD pipeline example
$
git add .github/ && git commit -m "Add CI/CD pipeline"
Commit and push to activate the workflow
$
gh run list --workflow=ci-cd.yml
Check recent pipeline run results
▼ show output
$
gh run watch
Watch a pipeline run in real time in your terminal
KNOWLEDGE CHECK

What is the difference between CI and CD?

Rate this lesson:
PreviousNext Lesson