Deploy Private GitHub Repos to Vercel Using GitHub Actions (No Upgrade Needed)

Deploy Private GitHub Repos to Vercel Using GitHub Actions (No Upgrade Needed)

678 views
Summary
Learn how to deploy private GitHub repositories to Vercel using GitHub Actions without upgrading to a Pro plan. This guide covers using the Vercel CLI, setting up a secure deployment pipeline, and adding production-ready checks like linting, testing, and build verification—all from a personal Vercel account.

✅ Deploying to Vercel from a Private GitHub Repo Using GitHub Actions (Without Upgrading)

Deploying to Vercel with a free plan is easy when using a personal Vercel account and the Vercel CLI. If you're working within an organization or team account on Vercel and don't want to upgrade, this guide will help you bypass that requirement using GitHub Actions and a manual deployment pipeline.

🔧 Requirements

  • A personal Vercel account (not a team/org)
  • A personal Vercel token
  • A private GitHub repo
  • Node.js project (Next.js, React, etc.)

🚀 Setting Up GitHub Actions for Vercel Deployment

Create a GitHub Actions workflow file at:

.github/workflows/deploy.yml

📝 Full deploy.yml Example

name: CI & Deploy to Vercel

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'

      - name: Install dependencies
        run: npm ci

      - name: Run linter
        run: npm run lint

      - name: Run tests
        run: npm test

      - name: Run build
        run: npm run build

      - name: Install Vercel CLI
        run: npm install -g vercel

      - name: Deploy to Vercel
        env:
          VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
        run: vercel --prod --yes --token $VERCEL_TOKEN

🛡️ Security Notes

  • Vercel token is stored securely in GitHub Secrets.
  • Only pushes to main trigger deployment.
  • Forks/clones cannot access your secrets and cannot deploy.

🔑 How to Generate and Use a Vercel Token

  1. Go to https://vercel.com/account/tokens
  2. Generate a personal token
  3. In GitHub, go to your repo → SettingsSecrets and variablesActions
  4. Add the token as a secret named VERCEL_TOKEN

🧹 Optional Commands for Production Readiness

You can add the following steps to your workflow:

Command Description
npm run lintRun ESLint
npm testRun unit tests
npm run buildCheck build success before deploy
npm run type-checkRun TypeScript checks
npx tsc --noEmitStandalone TypeScript check

🧪 Example package.json Scripts

"scripts": {
  "lint": "eslint .",
  "test": "jest",
  "build": "next build",
  "type-check": "tsc --noEmit"
}

❌ Avoiding the .vercel/project.json Issue

If your project contains:

{
  "projectId": "prj_abc123",
  "orgId": "team_xyz456"
}

Delete it to unlink the project from a team and allow CLI to create a new personal project on first deploy.

🧠 Tips & Best Practices

  • Use branches: Create dev/staging branches and deploy separately.
  • Protect main: Use branch protection rules in GitHub.
  • Review logs: Use both GitHub Actions and Vercel logs to debug.
  • Environment variables: Set via Vercel dashboard or CLI.

✅ Summary

What You Did Why It's Useful
Created GitHub Action with Vercel CLIAvoided Pro plan requirement
Used personal Vercel tokenBypassed org/team restriction
Added lint/test/build stepsImproved production safety
Scoped deploy to main branchPrevented unintentional deploys