- Update GitHub Actions CI workflow to use Node 22 - Add architecture and deadcode checks to CI pipeline - Create Vercel deployment guard script - Add comprehensive deployment documentation - Update README with CI badge and quality gates info - Configure vercel.json for deployment settings Vercel will now only deploy to production after all CI checks pass: - Linting & formatting - Type checking - Tests - Build verification - Architecture validation - Dead code detection See DEPLOYMENT.md for configuration instructions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.5 KiB
Deployment Configuration
This document explains how to configure Vercel to only deploy when GitHub Actions CI passes.
Overview
The project is configured to run comprehensive CI checks on every push and pull request:
- Linting - Code style and quality
- Type checking - TypeScript validation
- Tests - Unit and integration tests
- Build - Production build verification
- Architecture - Dependency rules validation
- Dead code - Unused code detection
Vercel should only deploy after all these checks pass on the main branch.
Configuration Options
There are two ways to prevent Vercel from deploying when CI fails:
Option 1: Vercel Deployment Protection (Recommended)
This is the simplest and most reliable approach.
-
Enable Deployment Protection in Vercel:
- Go to your Vercel project settings
- Navigate to Git → Deployment Protection
- Enable "Wait for Checks to Complete"
- This makes Vercel wait for all GitHub status checks before deploying
-
Configure Branch Protection (GitHub):
- Go to GitHub repository settings
- Navigate to Branches → Branch protection rules
- Add rule for
mainbranch - Enable "Require status checks to pass before merging"
- Select all CI jobs:
lint,type-check,test,build,architecture,deadcode - Enable "Require branches to be up to date before merging"
This ensures:
- ✅ PRs cannot be merged unless CI passes
- ✅ Vercel waits for CI to complete before deploying
- ✅ Production always has passing CI
Option 2: Ignored Build Step (Advanced)
Use a custom script to check CI status before building.
-
Add GitHub Token to Vercel:
- Go to Vercel project settings
- Navigate to Environment Variables
- Add
GITHUB_TOKENwith a Personal Access Token - Scope:
repo:status(read commit status) - Apply to: Production, Preview, Development
-
Configure Ignored Build Step:
- Go to Vercel project settings
- Navigate to Git → Ignored Build Step
- Set custom command:
bash scripts/vercel-should-deploy.sh
-
How it works:
- Script checks if CI has passed via GitHub API
- Exit code 0 = skip build (CI failed/pending)
- Exit code 1 = proceed with build (CI passed)
- Preview deployments always proceed
- Production deployments wait for CI
Deployment Workflow
For Pull Requests (Preview)
- Push commits to PR branch
- GitHub Actions runs CI checks
- Vercel creates preview deployment (regardless of CI status)
- CI status is shown on PR
- Can only merge if CI passes (branch protection)
For Production (Main Branch)
- PR is merged to
main - GitHub Actions runs CI checks
- Vercel waits for CI to complete (if Deployment Protection enabled)
- Once CI passes, Vercel deploys to production
- If CI fails, deployment is blocked
CI Jobs
The following jobs must pass for deployment:
| Job | Description | Blocks Deploy |
|---|---|---|
lint |
ESLint + Biome formatting | ✅ Yes |
type-check |
TypeScript compilation | ✅ Yes |
test |
Vitest unit tests | ✅ Yes |
build |
Production build | ✅ Yes |
architecture |
Dependency rules | ✅ Yes |
deadcode |
Unused code detection | ⚠️ Warning only |
Manual Deployment Override
If you need to deploy even when CI fails (emergency hotfix):
-
Temporarily disable branch protection:
- GitHub → Settings → Branches → Edit rule
- Uncheck "Require status checks to pass"
- Merge PR
- Re-enable protection immediately after
-
Or push directly to main (not recommended):
git push origin main --no-verify
Troubleshooting
Vercel deploys even though CI failed
Solution: Enable "Deployment Protection" in Vercel settings.
CI is stuck in pending state
Solution: Check GitHub Actions workflow logs. Ensure all jobs complete.
Preview deployments are blocked
Solution: Preview deployments should never be blocked. Check Ignored Build Step script logic.
Need to deploy urgently
Solution: Use manual override (see above), but fix CI issues immediately after.
Best Practices
- ✅ Always ensure CI passes before merging
- ✅ Use preview deployments to test changes
- ✅ Fix CI failures immediately - don't merge broken code
- ✅ Review CI logs when checks fail
- ❌ Don't bypass CI unless absolutely necessary
- ❌ Don't merge with failing tests "to fix later"
Verification
To verify the setup is working:
- Create a PR with intentionally broken code (e.g., TypeScript error)
- Verify CI fails
- Verify PR cannot be merged
- Verify Vercel deployment is blocked/skipped
- Fix the code
- Verify CI passes
- Verify PR can be merged
- Verify Vercel deploys successfully
Environment Variables
Required environment variables in Vercel:
| Variable | Required For | Description |
|---|---|---|
GITHUB_TOKEN |
Option 2 only | GitHub Personal Access Token with repo:status scope |
Not needed for Option 1 (Deployment Protection).
Status Badge
Add to README.md to show CI status:
[](https://github.com/YOUR_ORG/YOUR_REPO/actions/workflows/ci.yml)
Summary
Recommended Setup:
- Enable Vercel "Deployment Protection" (wait for checks)
- Enable GitHub branch protection for
main - Require all CI jobs to pass before merging
This ensures production always has high-quality, tested code.