GitHub Actions Deploy to Vercel Workflow

Generate a Vercel deployment GitHub Actions workflow with preview/prod gates

Build a GitHub Actions workflow that deploys to Vercel: preview builds on pull requests and production deploys on main merges, using the Vercel CLI with token, org ID, and project ID secrets handled correctly.

Why use the Vercel CLI instead of the Git integration?

The Vercel Git integration auto-deploys but gives you little control over build steps, gating, or running tests first. A CLI workflow lets you run lint and tests as a gate and deploy only after they pass, while still producing real Vercel deployments.

A continuous-deployment workflow lets every push and pull request build and deploy to Vercel automatically, with tests as a gate. This generator produces a ready-to-commit GitHub Actions YAML file that uses the official Vercel CLI to create preview deployments on pull requests and production deployments when you merge to your release branch.

How it works

The workflow uses three repository secrets — VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID — and follows Vercel’s recommended three-step CLI flow:

  1. vercel pull downloads the environment configuration for the target environment (preview or production).
  2. vercel build compiles the project locally into the .vercel/output directory.
  3. vercel deploy --prebuilt uploads that pre-built output, skipping a redundant remote build.

The job is conditioned on the event: pull requests run the preview path, and pushes to your chosen branch add the --prod flag so the deploy is promoted to your production domains.

Tips and notes

  • Run vercel link once locally to generate .vercel/project.json; its orgId and projectId are the values you store as secrets.
  • Add a separate test job that the deploy job needs: so a failing test blocks the deploy.
  • Use concurrency to cancel superseded preview deploys on the same branch and save build minutes.
  • The VERCEL_TOKEN should be a scoped token created under your Vercel account settings, not a personal access token with broad rights.