Creates Rivet namespaces for preview deployments.
| Input | Required | Default | Description |
|---|---|---|---|
platform |
Yes | - | Deployment platform (currently only vercel) |
rivet-token |
Yes | - | Rivet Cloud API token |
vercel-token |
No | - | Vercel API token (required when platform is vercel) |
rivet-endpoint |
No | https://api.rivet.dev |
Rivet Engine API endpoint |
github-token |
No | ${{ github.token }} |
GitHub token for PR comments |
main-branch |
No | main |
Main branch name for production deployments |
runner-config |
No | {} |
JSON object to override runner configuration |
-
Get your Rivet token from Rivet Dashboard > Settings > Advanced > Manual Client Configuration
-
Get your Vercel token from Vercel Account Settings
-
Add secrets to your repository:
gh secret set RIVET_CLOUD_TOKEN gh secret set VERCEL_TOKEN
-
Create
.github/workflows/rivet-preview.yml:name: Rivet Preview on: pull_request: types: [opened, synchronize, reopened] push: branches: [main] concurrency: group: rivet-preview-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: rivet-preview: runs-on: ubuntu-latest permissions: pull-requests: write steps: - uses: rivet-dev/preview-namespace-action@v1 with: platform: vercel rivet-token: ${{ secrets.RIVET_CLOUD_TOKEN }} vercel-token: ${{ secrets.VERCEL_TOKEN }}
When a PR is opened or updated:
- The action creates a Rivet namespace for the PR (or reuses an existing one)
- Environment variables (
RIVET_ENDPOINT,RIVET_PUBLIC_ENDPOINT) are set on Vercel for the branch - The action cancels the in-progress Vercel deployment and triggers a redeploy with the new environment variables
- Once the redeploy is complete, Rivet runners are configured to connect to the deployment
This redeploy step is necessary because Vercel starts building immediately when a commit is pushed, before the action has a chance to set the required environment variables. The action automatically handles this by triggering a fresh deployment after configuration is complete.
Deployment protection is automatically bypassed by generating a token via the Vercel API.