|
| 1 | +# Design Spec: Vercel Deploy + GitHub Actions CI/CD |
| 2 | + |
| 3 | +**Date:** 2026-03-23 |
| 4 | +**Status:** Implemented |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Context |
| 9 | + |
| 10 | +The Devmetry project (Next.js 16, React 19, pnpm, Biome.js, Jest) has no CI/CD or deployment setup. This spec covers: |
| 11 | + |
| 12 | +- Deploying the app to Vercel with automatic preview deploys on PRs |
| 13 | +- A GitHub Actions pipeline that runs lint, format check, tests, and build before any merge to `main` |
| 14 | +- Branch protection on `main` so merges are blocked if CI fails |
| 15 | + |
| 16 | +**Approach:** Vercel GitHub Integration + GitHub Actions CI + Branch Protection |
| 17 | + |
| 18 | +- Vercel handles all deploys (auto, via OAuth GitHub integration, no secrets needed in CI) |
| 19 | +- GitHub Actions validates quality gates on every PR and push |
| 20 | +- Branch protection on `main` enforces CI must pass before merge |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Architecture |
| 25 | + |
| 26 | +``` |
| 27 | +Push/PR |
| 28 | + └── GitHub Actions (ci.yml) ← quality gate |
| 29 | + ├── pnpm lint |
| 30 | + ├── pnpm exec biome format --check . |
| 31 | + ├── pnpm test --ci |
| 32 | + └── pnpm build |
| 33 | +
|
| 34 | + └── Vercel (GitHub Integration) ← auto deploy |
| 35 | + ├── PR → Preview Deploy (unique URL per PR) |
| 36 | + └── Merge to main → Production Deploy |
| 37 | +
|
| 38 | +Branch Protection (main): |
| 39 | + └── Requires "CI" status check to pass before merge |
| 40 | +``` |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## Key Decisions |
| 45 | + |
| 46 | +- `pnpm format` uses `--write` and is not safe for CI. Format check uses `pnpm exec biome format --check .` instead. |
| 47 | +- No environment variables needed — app is purely frontend. |
| 48 | +- Node 22 LTS, pnpm via corepack (`pnpm/action-setup@v4` reads `packageManager` from `package.json`). |
| 49 | +- pnpm store is cached by `pnpm-lock.yaml` hash to speed up installs. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## Files |
| 54 | + |
| 55 | +| File | Purpose | |
| 56 | +|---|---| |
| 57 | +| `.github/workflows/ci.yml` | GitHub Actions CI pipeline | |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Manual Setup Steps |
| 62 | + |
| 63 | +### Vercel |
| 64 | + |
| 65 | +1. Go to vercel.com → Add New Project → Import Git Repository |
| 66 | +2. Select the `devmetry` GitHub repo |
| 67 | +3. Framework preset: Next.js (auto-detected) |
| 68 | +4. Production branch: `main` |
| 69 | +5. Deploy — Vercel will auto-configure GitHub integration (preview on PRs, production on `main`) |
| 70 | + |
| 71 | +### GitHub Branch Protection |
| 72 | + |
| 73 | +1. GitHub → repo → Settings → Branches → Add branch ruleset (or classic rule) |
| 74 | +2. Branch name pattern: `main` |
| 75 | +3. Enable: "Require status checks to pass before merging" |
| 76 | +4. Add required status check: `CI` (matches the job name in `ci.yml`) |
| 77 | +5. Enable: "Require branches to be up to date before merging" |
| 78 | +6. Save |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## Verification |
| 83 | + |
| 84 | +1. Push `ci.yml` to a branch and open a PR → GitHub shows the "CI" check running |
| 85 | +2. Introduce a lint error → CI fails, merge is blocked |
| 86 | +3. Fix and re-push → CI passes, merge is unblocked |
| 87 | +4. After Vercel is connected: open a PR → Vercel preview URL appears in PR checks |
| 88 | +5. Merge to `main` → Vercel production deploy triggers automatically |
0 commit comments