master-project
CHAPTER 41 / 50
읽기 약 2분
FUNCTION
CI/CD: GitHub Actions → 자동 배포
핵심 개념
PR 검증·자동 배포·DB 마이그레이션·롤백 — 안전한 배포 파이프라인.
본문
CI 파이프라인
# .github/workflows/ci.yml
name: CI
on:
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with: { version: 9 }
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm typecheck
- name: Build
run: pnpm build
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL_STAGING }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY_STAGING }}
- name: Unit Tests
run: pnpm test
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4
with: { node-version: 20, cache: pnpm }
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install chromium
- run: pnpm test:e2eCD (Vercel 자동)
- main 브랜치 push → Vercel Production 자동 배포
- PR → Vercel Preview URL
- Vercel은 GitHub Action 외부에서 처리DB 마이그레이션 (수동 안전)
# .github/workflows/migrate.yml
name: DB Migration
on:
workflow_dispatch: # 수동 트리거
inputs:
env:
type: choice
options: [staging, production]
jobs:
migrate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with: { version: latest }
- name: Push migrations
run: |
supabase link --project-ref ${{ secrets.SUPABASE_PROJECT_REF_PROD }}
supabase db push
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}Branch Protection
GitHub → Settings → Branches → Add rule for main
✓ Require status checks: ci.yml + e2e
✓ Require branches up to date
✓ Require linear history
✓ Include administrators (선택)롤백 전략
[코드 롤백]
Vercel → Deployments → 이전 성공 배포 → "Promote to Production"
즉시 롤백 (5초)
[DB 롤백]
- 마이그레이션은 forward-only가 안전
- 컬럼 추가는 nullable로
- 이전 버전 코드와 호환되도록 작성기능 플래그 (Risk 감소)
// PostHog Feature Flag
import { useFeatureFlagEnabled } from 'posthog-js/react'
const isNewFeatureEnabled = useFeatureFlagEnabled('new-ai-feature')
return isNewFeatureEnabled ? <NewFeature /> : <OldFeature />배포 시간 단축
[Bottleneck]
- pnpm install: 1분
- TypeScript: 30초
- Build: 1-2분
- E2E: 3-5분
[최적화]
- pnpm cache (actions/cache)
- Turbo build (Turbopack)
- E2E 병렬 (--workers=4)
- 작은 커밋 단위 → 빠른 fixProduction 헬스체크
// src/app/api/health/route.ts
export async function GET() {
const supabase = await createClient()
const { error } = await supabase.from('users').select('id').limit(1)
if (error) return Response.json({ status: 'unhealthy' }, { status: 503 })
return Response.json({ status: 'healthy', version: process.env.VERCEL_GIT_COMMIT_SHA })
}외부 모니터링 (Uptime)
[옵션]
- BetterStack Uptime: 무료 10 monitor
- Pingdom
- StatusCake
설정: GET https://mysaas.com/api/health
- 1분 간격 체크
- 에러 시 이메일·SMS·Slack다음 챕터
CH.42 "성능 최적화: Lighthouse 90+ 달성".
AI 프롬프트
🤖 AI에게 잘 물어보는 법 — 모델·전략별 프롬프트
Claude
무료: Sonnet 4.6 / Pro $20/mo: Opus 4.6
내 마스터 프로젝트의 CI/CD 부분을 분석해서 실전 적용 + 개선 우선순위 3가지를 알려줘.
ChatGPT
무료: GPT-5.5 / Plus $20/mo: GPT-5.5 Pro
CI/CD 관련 모범 사례·안티패턴 5개를 비교 분석해서 실전 적용를 위한 추천 방안을 알려줘.
Gemini
무료: 2.5 Flash / Pro $19.99/mo: 3.1 Pro
내 프로젝트 전체에서 CI/CD 최적화 가능 위치와 리스크를 보고해줘.
Grok
무료: Grok 4.1 / SuperGrok $30/mo
2026년 한국 1인 개발자 시장의 CI/CD 트렌드와 차별화 포인트를 정리해줘.
⭐ 이것만 기억하세요
CI/CD: GitHub Actions → 자동 배포는 이 3가지만 확실히 잡으세요
1.GitHub Actions CI + Vercel CD = 자동 파이프라인
2.DB 마이그레이션은 수동 + forward-only
3.다음 챕터에서 성능 최적화
공유하기
진행도 41 / 50