Deploy Vercel projects from GitHub Actions with control over builds, environments, and integrations.
nexterias/actions-vercel is a GitHub Action that deploys Vercel projects from GitHub Actions. By building the project on the GitHub Actions runner when necessary and deploying it to Vercel, it can reduce Vercel-side build time to zero.
- 🚀 Switch between preview and production deployments.
- 🧹 Remove preview deployments from Vercel when their associated branches are deleted.
- 🏗️ Deploy the build result from GitHub Actions with
prebuilt: true. - 🔗 Integrate deployments with pull request comments, commit statuses, and GitHub Deployments.
- 🧩 Add custom steps such as tests and notifications before or after deployment.
name: Vercel
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.ref || github.ref }}
cancel-in-progress: true
on:
push:
pull_request:
delete:
jobs:
deploy:
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.event.deleted == false) }}
name: Deploy
runs-on: ubuntu-latest
permissions:
contents: read # Required to check out the repository.
deployments: write # (Optional) Create and update GitHub Deployments.
statuses: write # (Optional) Create and update commit statuses.
pull-requests: write # (Optional) Post comments on pull requests.
steps:
- uses: actions/checkout@v7
- uses: nexterias/actions-vercel@v2
with:
token: ${{ secrets.YOUR_VERCEL_TOKEN }}
org-id: ${{ secrets.YOUR_VERCEL_ORG_ID }}
project-id: ${{ secrets.YOUR_VERCEL_PROJECT_ID }}
production: ${{ github.ref == 'refs/heads/main' }}
prebuilt: true # If set to true, build will be performed using GitHub Actions.
# (Optional) When a branch is deleted from the remote repository,
# this job removes all preview deployments created for that branch from Vercel.
cleanup:
if: ${{ github.event_name == 'delete' && github.event.ref_type == 'branch' }}
name: Cleanup deployments
runs-on: ubuntu-latest
steps:
- uses: nexterias/actions-vercel@v2
with:
token: ${{ secrets.YOUR_VERCEL_TOKEN }}
org-id: ${{ secrets.YOUR_VERCEL_ORG_ID }}
project-id: ${{ secrets.YOUR_VERCEL_PROJECT_ID }}
cleanup-deployment: trueSee the documentation for detailed setup instructions and reference information.