This repository hosts a centralized GitHub Actions workflow to deploy multiple Vercel projects from a single location. This approach allows for a unified deployment strategy and easier secret management.
- Target Repo: A "Trigger Workflow" runs on push/PR, gathers context, and sends a
repository_dispatchevent. - Central Actions Repo: The "Deploy Workflow" listens for this event, checks out the code, and deploys it to Vercel using the provided Project IDs.
To enable auto-deployment for a new Next.js / Vercel project:
Go to your repository's Settings -> Secrets and variables -> Actions and add the following:
| Secret Name | Description | How to find it |
|---|---|---|
VERCEL_PROJECT_ID |
(Required per Repo) The ID of the project on Vercel. | Project Settings -> General -> Project ID. |
VERCEL_ORG_ID |
(Org Secret) The ID of your Vercel Team. | Already configured globally. |
Ensure the "Vercel Deploy Bot" (or your equivalent GitHub App) is installed on your new repository.
- Permissions needed: Read access to code, Write access to Pull Requests (for commenting).
Create a file named .github/workflows/vercel-trigger.yml in your new repository with the following content:
name: Request Central Vercel Deployment
on:
push:
branches: [main, master]
# pull_request: # Optional: Un-comment to deploy PRs
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Find open PR for this branch
id: pr
uses: jwalton/gh-find-current-pr@v1
- name: Dispatch to central repo
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.CENTRAL_DISPATCH_TOKEN }}
repository: eduport-tech/actions
event-type: vercel-commit
client-payload: >-
{
"repo": ${{ toJSON(github.repository) }},
"branch": ${{ toJSON(github.head_ref || github.ref_name) }},
"pr_number": ${{ toJSON(steps.pr.outputs.number) }},
"vercel_project_id": "${{ secrets.VERCEL_PROJECT_ID }}",
"vercel_org_id": "${{ secrets.VERCEL_ORG_ID }}"
}Ensure your organization secrets or repository secrets have CENTRAL_DISPATCH_TOKEN.
- This is a Classic PAT with
reposcope that has write access to theeduport-tech/actionsrepository.
These secrets must be configured in this actions repository for the deployment to work.
| Secret Name | Description |
|---|---|
VERCEL_TOKEN |
Vercel Account Token (Full Account scope). |
CI_APP_ID |
App ID of the GitHub App used for cloning/commenting. |
CI_APP_PRIVATE_KEY |
Private Key of the GitHub App. |
- "Repository not found" in Trigger: Check if
CENTRAL_DISPATCH_TOKENhas access toeduport-tech/actions. - "Project not found" in Vercel: Verify
VERCEL_PROJECT_IDmatches exactly. - "Author not in team": This workflow automatically removes
.gitto bypass this check, treating deployments as manual uploads by the token owner.