Preview deploys were failing due to missing env and token scopes
I consolidated env management using GitHub Environments + encrypted secrets
Added a preflight step to validate required vars before deploy
## Context
I've been wiring a Next.js dashboard with Supabase and Vercel. My CI/CD started flaking — preview builds failed while local dev worked fine. The culprit: environment variables and token scopes not flowing correctly in Actions.
## Solution
### 1) Centralize env and secrets
Use GitHub Environments (Preview/Production) for context-aware values
Store only what's needed: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID, SUPABASE_URL, SUPABASE_ANON_KEY, NEXT_PUBLIC_*
### 2) Preflight validation step
Fail fast if any required env is missing.
### 3) Deploy with scoped token
Ensure VERCEL_TOKEN has the minimal project scope.
### 4) Example workflow
Don't store Supabase service_role in GitHub — keep it out of CI unless absolutely necessary
Vercel envs must be created in the correct environment (Preview/Prod) or pull will fetch empty values
## Ask
How are you validating env drift between Vercel and GitHub? Any lightweight secret scanning step you recommend pre-merge?
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)