Apa Itu CI/CD?
CI/CD (Continuous Integration/Continuous Deployment) adalah praktik DevOps untuk mengotomatisasi proses build, test, dan deployment aplikasi.
Mengapa CI/CD?
- Faster Releases – Deploy lebih sering dan cepat
- Quality – Automated testing menangkap bug lebih awal
- Reliability – Deployment yang konsisten dan repeatable
- Developer Productivity – Less manual work, more coding
- Feedback Loop – Cepat mengetahui jika ada yang rusak
CI vs CD vs CD
- Continuous Integration (CI) – Automated build dan test pada setiap commit/PR
- Continuous Delivery (CD) – Automated deployment ke staging, manual deploy ke production
- Continuous Deployment (CD) – Fully automated deployment ke production
CI/CD Pipeline Stages
- Source – Code push ke repository (Git)
- Build – Compile, bundle, create artifacts
- Test – Unit tests, integration tests, E2E tests
- Security Scan – SAST, DAST, dependency scanning
- Deploy to Staging – Automated deployment ke staging
- Acceptance Tests – E2E tests di staging
- Deploy to Production – Automated atau manual
- Monitor – Health checks, alerting, logging
Tools CI/CD
CI/CD Platforms
- GitHub Actions – Built into GitHub, YAML-based
- GitLab CI – Built into GitLab, powerful
- Jenkins – Open source, highly customizable
- CircleCI – Cloud-based, fast
- Azure DevOps – Microsoft ecosystem
- AWS CodePipeline – AWS ecosystem
Container and Orchestration
- Docker – Containerization
- Kubernetes – Container orchestration
- Helm – Kubernetes package manager
Testing Tools
- Jest / Vitest – JavaScript testing
- PyTest – Python testing
- PHPUnit – PHP testing
- Cypress / Playwright – E2E testing
- SonarQube – Code quality
Contoh GitHub Actions Workflow
# .github/workflows/ci.yml
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
- name: Build
run: npm run build
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to server
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/app
git pull origin main
npm ci --production
pm2 restart app




