▲ Vercel Preview Github Action

Overview

Vercel Preview Deployments Github Action

Snappy looking through a magnifier with the Vercel logo in its center

Trigger Vercel preview deployments when you want to integrate with external services smoothly.

Vercel preview deployments happen automatically with each commit. This action allows you to take control over automatic deployments, which is helpful when you want to create external resources (like a database) and wait for services to be ready before deploying your code on Vercel.

Combine this action with snaplet/action to get preview databases with production-accurate data for each of your Vercel preview deployment. Learn more here.

Usage

Create a GitHub Action Workflow file in your repository following one of these examples.

Standalone

# .github/workflows/preview.yml

name: Preview Environment

env:
  VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}
  VERCEL_PROJECT_ID: <YOUR_VERCEL_PROJECT_ID>

on:
  pull_request:
    types: [opened, synchronize, closed]
    branches:
      - main

jobs:
  deploy:
    if: ${{ github.event.action == 'opened' || github.event.action == 'synchronize' }}
    runs-on: ubuntu-latest
    steps:
      - uses: snaplet/vercel-action@v1
  delete:
    if: ${{ github.event.action == 'closed' }}
    runs-on: ubuntu-latest
    steps:
      - uses: snaplet/vercel-action@v1
        with:
          delete: true

With Snaplet

Using snaplet/action

# .github/workflows/preview.yml

name: Preview Environment

env:
  SNAPLET_ACCESS_TOKEN: ${{ secrets.SNAPLET_ACCESS_TOKEN }}
  SNAPLET_PROJECT_ID: <YOUR_SNAPLET_PROJECT_ID>
  VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}
  VERCEL_PROJECT_ID: <YOUR_VERCEL_PROJECT_ID>

on:
  pull_request:
    types: [opened, synchronize, closed]
    branches:
      - main

jobs:
  deploy:
    if: ${{ github.event.action == 'opened' || github.event.action == 'synchronize' }}
    runs-on: ubuntu-latest
    steps:
      - id: snaplet
        uses: snaplet/action@v1
      - uses: snaplet/vercel-action@v1
        with:
          env: |
            DATABASE_URL=${{ steps.snaplet.outputs.database-url }}
  delete:
    if: ${{ github.event.action == 'closed' }}
    runs-on: ubuntu-latest
    steps:
      - uses: snaplet/action@v1
        with:
          delete: true
      - uses: snaplet/vercel-action@v1
        with:
          delete: true

Documentation

Prerequisites

Connect your GitHub repository with Vercel

Environment variables

  • VERCEL_ACCESS_TOKEN
  • VERCEL_PROJECT_ID

Inputs

delete:
  description: Delete the preview related data on Vercel
  required: false
  type: boolean
  default: false
env:
  description: Environment variables to create on Vercel, they are scoped to the "preview" environment and the current branch
  required: false
  type: string
You might also like...

A GitHub Action to cache your workload to a Google Cloud Storage bucket.

A GitHub Action to cache your workload to a Google Cloud Storage bucket.

Google Cloud Storage Cache Action GitHub already provides an awesome action to cache your workload to Azure's servers hosted in United States. However

Dec 15, 2022

🤖 GitHub Action which creates Issues from comments in your code

🤖 GitHub Action which creates Issues from comments in your code

todo-issue[action] Disclosure Huge thanks to JasonEtco! After he decided to shut down his todo[bot] I've looked around for alternatives but decided to

Dec 11, 2022

GitHub action to install Foundry

foundry-toolchain Action This GitHub action installs Foundry. Example workflow on: [push] name: test jobs: check: name: Foundry project ru

Jan 5, 2023

Github action to parse OWNERS files and outputs random reviewers

Get Owners Github Action Do you want to have all the approvers and reviewers without having strange scripts in your actions? Do you want to have rando

Oct 22, 2022

GitHub action code for VMware Image Builder (VIB).

VMware Image Builder Overview This GitHub Action allows to interact with the VMware Image Builder service from VMware, a.k.a. VIB. VIB is a SaaS servi

Dec 22, 2022

⚙️ A GitHub Action to push a feed item to RSS3 network

RSS3 Github Action Update a users feed to reflect changes in a Github Repository. Setup Have a copy of your private key Add an environment secret to y

Apr 26, 2022

🚀 A GitHub action to publish a new release of the repository

Create a JavaScript Action using TypeScript Use this template to bootstrap the creation of a TypeScript action. 🚀 This template includes compilation

Nov 1, 2022

💅 A ready-to-go with a well-thought-out structure Electron app boilerplate with ReactJS, TypeScript, CSS / SASS modules, SWC, Eslint, Prettier, GitHub Action releases and more.

💅 A ready-to-go with a well-thought-out structure Electron app boilerplate with ReactJS, TypeScript, CSS / SASS modules, SWC, Eslint, Prettier, GitHub Action releases and more.

Electron App 💅  A ready-to-go with a well-thought-out structure Electron app boilerplate with ReactJS, TypeScript, CSS / SASS modules, SWC, Eslint, P

Dec 29, 2022

This GitHub Action will setup a Nushell environment for you.

setup-nu 中文说明 This GitHub Action will setup a Nushell environment for you. Usage Examples In most cases you need to specify the version of Nushell to

Dec 30, 2022
Comments
  • Github Action failing with message

    Github Action failing with message "Failed to parse URL from undefined"

    This is my workflow file:

    name: Vercel Preview Deployment
    
    env:
      VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}
      VERCEL_PROJECT_ID: <project-id>
    
    on:
      pull_request:
        types: [opened, synchronize, closed]
    
    jobs:
      deploy-vercel-preview:
        if: ${{ github.event.action == 'opened' || github.event.action == 'synchronize' }}
        runs-on: ubuntu-latest
        steps:
          - uses: snaplet/vercel-action@v2
      delete-vercel-preview:
        if: ${{ github.event.action == 'closed' }}
        runs-on: ubuntu-latest
        steps:
          - uses: snaplet/vercel-action@v2
            with:
              delete: true
    

    Based on the above workflow file, I'm getting the following error message when a new pull request is created:

    Creating deploy hook...
    Deploy hook created.
    Creating deployment...
    node:internal/deps/undici/undici:5573
                throw new TypeError("Failed to parse URL from " + input, { cause: err });
                      ^
    
    TypeError: Failed to parse URL from undefined
        at new Request (node:internal/deps/undici/undici:5573:19)
        at Agent.fetch2 (node:internal/deps/undici/undici:6[37](https://github.com/realtimeskills/oslash/actions/runs/3636809230/jobs/6137131079#step:2:40)1:25)
        ... 2 lines matching cause stack trace ...
        at processTicksAndRejections (node:internal/process/task_queues:96:5) {
      [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
          at new NodeError (node:internal/errors:387:5)
          at URL.onParseError (node:internal/url:565:9)
          at new URL (node:internal/url:641:5)
          at new Request (node:internal/deps/undici/undici:5571:25)
          at Agent.fetch2 (node:internal/deps/undici/undici:6371:25)
          at fetch (node:internal/deps/undici/undici:7200:20)
          at file:///home/runner/work/_actions/snaplet/vercel-action/v2/scripts/deploy.mjs:49:23
          at processTicksAndRejections (node:internal/process/task_queues:96:5) {
        input: 'undefined',
        code: 'ERR_INVALID_URL'
      }
    }
    Error: Process completed with exit code 1.
    
    opened by DaniAkash 2
  • feat: add await-for-deployment and ignored-build-command inputs

    feat: add await-for-deployment and ignored-build-command inputs

    In this PR I added two new inputs:

    • await-for-deployment which will wait for the deployment to be ready before exiting the action. It will also output the deployment-url to be used in subsequent steps like e2e tests.
    • ignored-build-command which can now be customized. This command is used to short-circuit Vercel Github App and skip the preview deployments coming from it, so only the ones triggered by the GitHub action with deploy hooks are allowed.
    opened by jgoux 0
  • Github is deprecating set-output command

    Github is deprecating set-output command

    I'm getting a warning in my action that Github is deprecating the set-output command. Setting the deployment URL here should probably write to the GITHUB_OUTPUT environment variable.

    opened by lorenries 0
Releases(v2.0.0)
Codebraid Preview provides a Markdown preview for Pandoc documents within VS Code.

Codebraid Preview provides a Markdown preview for Pandoc documents within VS Code. Most Markdown previews don't support all of Pandoc's extensions to Markdown syntax. Codebraid Preview supports 100% of Pandoc features—because the preview is generated by Pandoc itself! There is also full bidirectional scroll sync and document export.

Geoffrey Poore 12 Dec 28, 2022
Get an isolated preview database for every Netlify Preview Deployment

Netlify Preview Database Plugin Create an isolated preview database for each preview deployment in Netlify Quickstart • Website • Docs • Discord • Twi

Snaplet 10 Nov 16, 2022
GitHub Action that posts the report in a comment on a GitHub Pull Request from coverage data generated by nyc (istanbul)

GitHub Action: Report NYC coverage GitHub Action that posts the report in a comment on a GitHub Pull Request from coverage data generated by nyc (ista

Sid 16 Nov 23, 2022
A GitHub action to submit your dependency graph from your Mill build to GitHub.

Mill Dependency Submission A GitHub action to submit your dependency graph from your Mill build to GitHub via their Dependency Submission API. The mai

Chris Kipp 6 Dec 15, 2022
A GitHub Action that allows to debug GitHub workflows using VS Code.

VS Code Server Action A GitHub Action that allows to debug GitHub workflows using VS Code. Failing CI builds can be annoying especially since we don't

stateful 18 Dec 23, 2022
Minimal, SEO-focused website starter kit powered by Notion, GitHub, and Vercel.

wr8 wr8 lets you create a website in Notion with better SEO. It is a customized version of nextjs-notion-starter-kit, based on NotionX. Introduction T

Verfasor 7 Dec 22, 2022
A github action that provides detailed bundle analysis on PRs for next.js apps

Next.js Bundle Analysis Github Action Analyzes each PR's impact on your next.js app's bundle size and displays it using a comment. Optionally supports

HashiCorp 369 Dec 27, 2022
A custom action for setting GitHub Workflow environment variables with YAML configuration files.

yaml-env-action - A custom action for setting GitHub Workflow environment variables with YAML configuration files. Introduction yaml-env-action is a c

Piper Dougherty 3 Dec 13, 2022
Setup-graalvm - GitHub Action for setting up GraalVM CE.

GitHub Action for GraalVM This GitHub action sets up GraalVM Community Edition and GraalVM components such as Native Image and GraalVM languages. Key

GraalVM 105 Jan 2, 2023
A GitHub Action for pushing to a repo.

action-gh-push A GitHub Action for pushing to a repo. ?? Usage Below is a simple example of step.if tag gating name: ci on: push jobs: build:

迷渡 6 Feb 15, 2022