neondatabase / preview-branches-with-vercel

Example project that shows how you can create a branch for every preview deployment on Vercel using GitHub actions
29 stars 11 forks source link
branching neon preview-deploy preview-environment vercel

Preview Branches for every Vercel Preview Deployment

This is an example project that shows how you can create a branch for every preview deployment on Vercel.

How it works

There are two workflows in this project:

Prerequisites

For the workflows to work, you need to add the following secrets to your GitHub repository:

If you're unfamiliar with how to add secrets to a GitHub repository, you can read more about in GitHub's documentation.

Ignored build step

Since we're creating preview deployments using GitHub actions, it's a good idea to disable the build step on Vercel.

set up project locally

If you want to use this project as a playground, you can you can set it up locally.

  1. Clone this repo
git clone
  1. Install dependencies
npm install
  1. Copy the .env.example file to .env:
cp .env.example .env
  1. Add the database credentials:
DATABASE_URL = "" # the pooled connection to the database. It has a `-pooler` suffix
DIRECT_DATABASE_URL = "" # the direct connection string to the database
  1. Run the setup script which creates the tables and runs a seed script:
npm run setup
  1. Deploy the project to Vercel

  2. Open a pull request and see the preview deployment in action