~/gvndsxnkr
cd ../notes

// ci/cd · infrastructure · 4 min read

Automating Cross-Account Vercel Deployments with GitHub Actions

Deploying private organization repositories cleanly into external client Vercel environments.

A common setup in client work: the code lives in my GitHub organisation, but the app must run in the client's Vercel account, which they own and pay for. Vercel's Git integration assumes the repository and the project belong to the same team, so connecting them directly either fails or means handing the client access to private repositories.

The fix is to stop letting Vercel pull from Git, and push builds to it from GitHub Actions with the Vercel CLI instead.

How it fits together

  1. The client creates the project in their Vercel team and generates an access token.
  2. The project's org ID and project ID, plus the token, are stored as GitHub Actions secrets in my repository.
  3. On every push, a workflow pulls the project settings, builds, and deploys the prebuilt output to the client's project.

The repository never has to be shared, and the client keeps full ownership of hosting, domains and billing.

The workflow

name: Deploy to client Vercel

on:
  push:
    branches: [main]

env:
  VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
  VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm install --global vercel@latest
      - run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
      - run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
      - run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

vercel pull downloads the project settings and environment variables from the client's project, vercel build builds on the runner, and vercel deploy --prebuilt uploads only the output. The repository is never connected to the client's Vercel project. The token can still deploy anything within its scope, though, so who holds it matters (see below).

Previews for pull requests

The same pattern gives you preview deployments. Run the steps on pull_request, use --environment=preview, drop --prod, and post the URL that vercel deploy prints as a PR comment. Reviewers get a live link without anyone touching the Vercel dashboard.

Things that bite

  • Turn off Vercel's own Git deployments for the project, or you will get duplicate or failed builds.
  • Scope the token tightly. Ask the client for a token limited to their team, with the narrowest scope Vercel offers. Store it only as a GitHub Actions secret, and rotate it when the engagement ends.
  • Environment variables live in Vercel, so the client manages their own secrets. But vercel pull writes them onto the CI runner for the duration of the job. Use GitHub's ephemeral hosted runners, and never print or upload the pulled .vercel directory.
  • Commit-author checks are a trade-off, not a nuisance. For private repositories, Vercel can refuse a deployment whose Git commit author isn't a member of the team that owns the project. In this setup the author never is. We deploy prebuilt output and remove the Git metadata (rm -rf .git) before vercel deploy --prebuilt. That's a deliberate choice: the deployment is no longer linked to a commit inside Vercel, so you lose Vercel's commit-based history and Git-integration features. Traceability moves to the GitHub Actions run that produced it, and Vercel's Deployment Protection still controls who can view previews. The client should agree to this explicitly, not discover it later.
  • Organise workflows per app or with one reusable workflow. With standalone repositories, each app deploys to its own project on its own schedule. A reusable workflow that takes the project as an input works just as well.

The result is a clean split of responsibilities: I own the code and the pipeline, the client owns the infrastructure, and nobody has to share credentials they shouldn't.

  • #CI/CD
  • #Infrastructure