```html CI/CD Pipeline Setup Checklist

CI/CD Pipeline Checklist

Docker · GitHub Actions · Web Deploy

0/0
0%

Docker Setup

0/3

Dockerfile, ignore rules, image optimization

Tạo Dockerfile multi-stage build Required

Dùng FROM node:20-alpine AS builderFROM nginx:alpine để giảm image size production.

Cấu hình file .dockerignore Important

Loại trừ node_modules, .git, .env, dist để tránh copy file không cần thiết vào image.

Kiểm tra image size sau build Check

Chạy docker images và verify size ≤ 50MB cho app thông thường. Dùng docker dive để phân tích layer.

GitHub Actions CI

0/3

Workflow file, caching, test automation

Tạo file workflow .github/workflows/ci.yml Required

Định nghĩa on: push/pull_request, jobs buildtest chạy song song để tiết kiệm thời gian.

Bật npm cache trong workflow Important

Dùng actions/setup-node với cache: 'npm' để cache node_modules, giảm 2-3 phút build time.

Cấu hình test coverage report Important

Thêm npm run test:coverage và upload kết quả lên Codecov hoặc GitHub Artifacts để track coverage trend.

Secrets Management

0/3

Bảo mật API keys, environment variables

Thêm secrets vào GitHub Repository Required

Vào Settings → Secrets and variables → Actions. Thêm DOCKER_TOKEN, DEPLOY_KEY, SENTRY_DSN.

Bật Environment Protection Rules Important

Tạo environment production với required reviewers. Deploy lên production chỉ sau khi được approve thủ công.

Kiểm tra .gitignore che đủ file nhạy cảm Required

Đảm bảo .env, .env.local, *.pem, secrets/ đã được ignore. Dùng git-secrets để scan.

Preview Deployment

0/3

Vercel / Netlify preview URL cho mỗi PR

Kết nối GitHub repo với Vercel hoặc Netlify Required

Import project trên dashboard, cấu hình build command npm run build và output directory dist hoặc out.

Xác nhận preview URL được tạo tự động trên PR Important

Tạo một test PR và kiểm tra bot comment URL preview dạng app-git-branch.vercel.app trong vòng 2 phút.

Thêm Lighthouse CI check trên preview URL Optional

Dùng treosh/lighthouse-ci-action để auto-check performance score trước khi merge, threshold ≥ 80.

Monitoring & Error Tracking

0/3

Sentry integration, source maps, alerting

Tích hợp Sentry SDK vào project Required

Cài @sentry/react hoặc @sentry/nextjs. Init với DSN từ GitHub Secret, bật tracesSampleRate: 0.1 cho production.

Upload source maps sau mỗi deployment Important

Thêm bước sentry-cli releases upload-sourcemaps vào workflow sau build. Đảm bảo SENTRY_AUTH_TOKEN có trong secrets.

Test error tracking hoạt động đúng Check

Trigger test error thủ công bằng Sentry.captureException(new Error("test")) và xác nhận hiển thị trên Sentry dashboard với source map đúng.

Cost Optimization

0/3

Tối ưu GitHub Actions minutes, caching

Bật Docker layer caching trong workflow Important

Dùng cache-from: type=ghacache-to: type=gha,mode=max trong bước docker/build-push-action.

Dùng paths-filter để skip job không liên quan Important

Dùng dorny/paths-filter — chỉ chạy test backend khi có thay đổi trong src/api/**, tránh lãng phí minutes.

Kiểm tra usage trên GitHub Billing dashboard Check

Vào Settings → Billing → Actions. Xem minutes consumed, set spending limit. Free tier: 2,000 min/tháng cho private repos.

```