← 커리큘럼 홈
★ GitHub Actions + Vercel + Test 게이트 · BONUS

코드를 푸시하면
자동으로 검증·배포

Vercel은 GitHub 연결만으로 절반은 됩니다. 나머지 절반 — 테스트 게이트·자동 롤백·preview 환경·알림 — 을 GitHub Actions로 채웁니다.

"매 커밋마다 자동 검증이 1인 사고 방지의 마지막 선"

§1. CI/CD 파이프라인 전체 그림

push → 검증 → 배포 → 알림 5단계

STEP 01
📤
git push
로컬 → GitHub
STEP 02
🧪
CI 검증
typecheck · lint · test · build
STEP 03
🚀
자동 배포
PR → Preview / main → Prod
STEP 04
smoke test
배포 직후 핵심 흐름 검증
STEP 05
🔔
텔레그램 알림
성공·실패 자동 통보
🎯 1인 SaaS의 CI/CD가 풀어야 할 3가지
1. "내가 짠 코드가 진짜 작동하나" — 자동 테스트
2. "배포 후 사이트 안 죽었나" — Smoke test
3. "사고 나면 1분 안에 알 수 있나" — 자동 알림

이 3가지만 자동화되면 Stage 5의 Stop Hook과 합쳐 거의 모든 사고 방어.

§2. 3환경 분리 — Dev / Preview / Production

로컬
Development
URL: localhost:3000
DB: Supabase 로컬 또는 별도 dev 프로젝트
결제: 토스 테스트 키
env: .env.local
main 브랜치만
Production
URL: my-newsletter.vercel.app
DB: production Supabase
결제: 토스 실 키
env: Vercel Production env
⚠️ Production DB를 dev에서 절대 건들지 말 것
가장 흔한 1인 사고 — 로컬 .env.local에 production Supabase URL이 남아있어서 테스트 데이터가 production DB에 들어감. 해결: .env.local은 항상 dev 프로젝트만. production env는 Vercel 대시보드에서만 관리.

§3. GitHub Actions — 핵심 워크플로우

.github/workflows/ 폴더에 yml 파일 1개. 매 push에 자동 실행

.github/workflows/ci.yml 검증 게이트
name: CI on: push: branches: [main] pull_request: branches: [main] jobs: verify: runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' cache: 'pnpm' - uses: pnpm/action-setup@v4 with: { version: 9 } - run: pnpm install --frozen-lockfile - run: pnpm typecheck - run: pnpm lint - run: pnpm test:ci # Build 검증 (env 없어도 build만) - run: pnpm build env: NEXT_PUBLIC_SUPABASE_URL: 'https://placeholder.supabase.co' NEXT_PUBLIC_SUPABASE_ANON_KEY: 'placeholder' e2e: runs-on: ubuntu-latest needs: verify timeout-minutes: 15 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: '20', cache: 'pnpm' } - uses: pnpm/action-setup@v4 - run: pnpm install --frozen-lockfile - run: pnpm exec playwright install chromium - run: pnpm exec playwright test env: PLAYWRIGHT_BASE_URL: 'http://localhost:3000' - if: failure() uses: actions/upload-artifact@v4 with: name: playwright-report path: playwright-report/
✅ Vercel은 자동 — Actions는 검증만
Vercel이 GitHub 연결돼 있으면 push마다 자동 배포 (Preview·Production). GitHub Actions는 "배포 전 검증"만 담당. 이중 작업 안 함. Actions가 fail이어도 Vercel은 배포 — 따로 막으려면 deployment protection 설정.

§4. 배포 후 Smoke Test — 살았는지 확인

"빌드 성공 = 사이트 살음"이 아님. 진짜 200 응답 받는지

.github/workflows/smoke.yml 배포 후
name: Smoke Test on: deployment_status: # Vercel 배포 완료 후 자동 jobs: smoke: if: github.event.deployment_status.state == 'success' runs-on: ubuntu-latest steps: - name: Health check run: | URL="${{ github.event.deployment_status.target_url }}" curl -fsSL "$URL/" > /dev/null curl -fsSL "$URL/stage1" > /dev/null curl -fsSL -X POST "$URL/api/chat" \ -H "Content-Type: application/json" \ -d '{"system":"한 단어 답.","messages":[{"role":"user","content":"hi"}],"max_tokens":10}' - name: 텔레그램 성공 알림 if: success() run: | curl -X POST "https://api.telegram.org/bot${{ secrets.TG_BOT }}/sendMessage" \ -d chat_id="${{ secrets.TG_CHAT }}" \ -d text="✅ 배포 OK · $URL" - name: 텔레그램 실패 알림 if: failure() run: | curl -X POST "https://api.telegram.org/bot${{ secrets.TG_BOT }}/sendMessage" \ -d chat_id="${{ secrets.TG_CHAT }}" \ -d text="🚨 배포 후 smoke test 실패 · $URL"

§5. 자동 롤백 — 사고 시 1분 복구

production이 망가졌을 때 가장 빠른 복구 = 이전 배포로 즉시 되돌리기. Vercel CLI 한 줄로 가능. GitHub Actions에 미리 셋업해두면 텔레그램 알림 받자마자 바로 실행.

긴급 롤백 — 1줄 로컬 또는 GitHub Actions
# 방법 1 — Vercel CLI 직접 $ vercel rollback # 직전 배포로 $ vercel rollback dpl_xxx # 특정 배포 ID로 # 방법 2 — GitHub Actions 수동 트리거 # .github/workflows/rollback.yml on: workflow_dispatch: # 수동 실행 버튼 inputs: reason: { description: '롤백 사유', required: true } jobs: rollback: runs-on: ubuntu-latest steps: - run: npx vercel rollback --token=${{ secrets.VERCEL_TOKEN }} - run: | curl -X POST "https://api.telegram.org/bot${{ secrets.TG_BOT }}/sendMessage" \ -d chat_id="${{ secrets.TG_CHAT }}" \ -d text="⚠️ 롤백 실행됨: ${{ inputs.reason }}"
🚨 롤백 후 반드시
① 사용자에게 "일시적 장애 → 복구 완료" 공지
② DB는 롤백 안 됨 (코드만 롤백) — 데이터 정합성 확인
③ 원인 분석 + CLAUDE.md "실전 교훈"에 추가

§6. GitHub Secrets — 키 안전하게

GitHub Actions에서 사용할 모든 키는 repo → Settings → Secrets and variables → Actions에 등록. 절대 yml에 직접 쓰지 말 것.

VERCEL_TOKEN — Vercel 대시보드 → Settings → Tokens 발급
VERCEL_ORG_ID + VERCEL_PROJECT_IDvercel link 실행 후 .vercel/project.json에서 확인
TG_BOT + TG_CHAT — 텔레그램 봇 토큰 + chat ID
SUPABASE_SERVICE_KEY — E2E 테스트용 (production 아닌 dev 프로젝트만!)
ANTHROPIC_API_KEY — smoke test에서 /api/chat 검증 시 (또는 별도 테스트 키)
⚠️ Secret 회전
6개월에 한 번 모든 토큰 재발급. 회전 후 GitHub Secrets·Vercel env·로컬 .env.local 모두 같은 날에 동기화. 잊으면 다음 push에서 CI 실패.

§7. 1인 SaaS 권장 워크플로우 — 단순하게

단계해야 함안 해도 됨
출시 직전 (MVP) main에 push → Vercel 자동 배포 + Sentry CI/CD·E2E·롤백 자동화 (오버킬)
유료 구독자 1~10명 + ci.yml (typecheck·lint·test) + smoke test 여전히 단순. CI는 가벼운 게이트만
10~100명 + E2E 테스트 + 텔레그램 알림 + 자동 롤백 셋업 다중 환경 분리는 아직 X
100~1000명 + Preview 환경 + DB 마이그레이션 자동화 + 보안 스캔 마이크로서비스·Kubernetes (오버킬)
🎯 가장 큰 함정 — 처음부터 풀스펙 CI/CD
유료 구독자 0명인데 GitHub Actions 5개·환경 3개·Slack 통합... = 배포 자체가 1시간씩 걸림. 유료 구독자 수에 비례해서 점진적으로 추가. Vercel 자동 배포 한 가지만으로도 첫 1주는 충분.