2025-03-10•Abyan Dimas
Building Your First CI/CD Pipeline with GitHub Actions
Manual deployments are risky. CI/CD (Continuous Integration/Continuous Deployment) removes human error. GitHub Actions makes this free and easy.
The Workflow File
Create .github/workflows/ci.yml.
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install dependencies
run: npm ci
- name: Run Tests
run: npm test
- name: Build
run: npm run build
What does this do?
- Trigger: Runs on every
pushto the repository. - Environment: Spins up a virtual Ubuntu server.
- Steps: Checks out code, installs Node, installs dependencies, runs tests, and builds the app.
If any step fails (e.g., a test breaks), GitHub will alert you, and you (or your team) won't merge the broken code. That is the power of CI.