Skip to content

Genetica-Corp/wait-for-vercel-preview

 
 

Repository files navigation

Wait for Vercel Preview — A GitHub Action ⏱

Do you have other Github actions (Lighthouse, Cypress, etc) that depend on the Vercel Preview URL? This action will wait until the url is available before running the next task.

Please note that this action is supposed to be run on the pull_request or push events.

Inputs

token (Required)

The github secret ${{ secrets.GITHUB_TOKEN }}

environment

Optional — The name of the environment that was deployed to (e.g., staging or production)

max_timeout

Optional — The amount of time to spend waiting on Vercel. Defaults to 60 seconds

allow_inactive

Optional - Use the most recent inactive deployment (previously deployed preview) associated with the pull request if no new deployment is available. Defaults to false.

check_interval

Optional - How often (in seconds) should we make the HTTP request checking to see if the deployment is available? Defaults to 2 seconds.

vercel_password

Optional - The password for the deployment

vercel_protection_bypass_header

Optional - The header to bypass protection for automation

path

Optional - The URL that tests should run against (eg. path: "https://vercel.com").

pr_number

If running this action from a non pull_request event, such as issue_created, you can provide the PR number directly. For example:

steps:
  - uses: patrickedqvist/wait-for-vercel-preview@v1.3.3
    id: waitFor200
    with:
      token: ${{ secrets.GITHUB_TOKEN }}
      pr_number: ${{ github.event.issue.number }}

Outputs

url

The vercel deploy preview url that was deployed.

vercel_jwt

If accessing a password protected site, the JWT from the login event. This can be passed on to e2e tests, for instance.

sha

The SHA of the commit corresponding to the deployment.

Example usage

Basic Usage

steps:
  - name: Waiting for 200 from the Vercel Preview
    uses: patrickedqvist/wait-for-vercel-preview@v1.3.1
    id: waitFor200
    with:
      token: ${{ secrets.GITHUB_TOKEN }}
      max_timeout: 60
  # access preview url
  - run: echo ${{steps.waitFor200.outputs.url}}

Building

The Action is bundled via ncc. See this discussion for more information.

npm run build
# outputs the build to dist/index.js

Tests

Unit tests with Jest and Mock Service Worker

npm test

About

A github action for waiting for the vercel preview

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%