| Branch | Target | How |
|---|---|---|
main |
GitHub Pages (production) | GitHub Actions |
staging |
Vercel (staging) | GitHub Actions |
Create two environments in Repo → Settings → Environments:
| Variable | Description |
|---|---|
NEXT_PUBLIC_API_URL |
Production API base URL |
NEXT_PUBLIC_GA_MEASUREMENT_ID |
Google Analytics measurement ID |
| Variable | Description |
|---|---|
NEXT_PUBLIC_API_URL |
Staging API base URL |
NEXT_PUBLIC_GA_MEASUREMENT_ID |
Google Analytics measurement ID |
VERCEL_ORG_ID |
From vercel link (see below) |
VERCEL_PROJECT_ID |
From vercel link (see below) |
VERCEL_TOKEN |
Vercel personal access token |
STAGING_DOMAIN |
e.g. zero-staging.smalltech.in |
Run inside the code/ folder:
cd code
npx vercel link- Select your team/account and existing project when prompted.
- Open the generated file:
cat .vercel/project.json{
"orgId": "...",
"projectId": "..."
}orgId→VERCEL_ORG_IDprojectId→VERCEL_PROJECT_ID
Vercel Dashboard → Settings → Tokens → Create Token → copy once.
Add a CNAME record with your DNS provider:
| Field | Value |
|---|---|
| Name | staging |
| Target | cname.vercel-dns.com |
Then add staging.yourdomain.com in Vercel → Project → Settings → Domains.
On push to main:
- Writes
code/.env.productionfromproductionenvironment variables - Runs
npx next build(static export) - Deploys
out/to GitHub Pages
On push to staging:
- Runs
vercel deploy --prodwithNEXT_PUBLIC_*vars passed as--build-env - Aliases the deployed URL to
STAGING_DOMAIN