0.0.8 • Published 3 years ago

vercel-is-pull-request v0.0.8

Weekly downloads
30
License
MIT
Repository
github
Last release
3 years ago

vercel-is-pull-request

CLI which adds pull request environment variables to Vercel builds.

It adds the following variables:

NameDescription
VERCEL_GIT_IS_PULL_REQUESTAn indicator that the current build has a corresponding pull request. Example: 1.
VERCEL_GIT_PULL_REQUEST_NUMBERThe pull request number the build corresponds to. Example: 36. This is only set if VERCEL_GIT_IS_PULL_REQUEST is 1.

Usage

To use this, first install it as a dependency.

npm install vercel-is-pull-request

Then, update your install command to include the following command:

source node_modules/.bin/vercel-is-pull-request

If you are building a private GitHub repository add a access token through the --auth argument like so:

source node_modules/.bin/vercel-is-pull-request --auth githubaccesstoken

Screenshot of updating vercel install command to include vercel-is-pull-request

Now inside your build step you can access the added environment variables to change the build.

if (process.env.VERCEL_GIT_IS_PULL_REQUEST === '1') {
  console.log(`Building preview of pull request: https://github.com/useparcel/vercel-is-pull-request/pulls/${process.env.VERCEL_GIT_PULL_REQUEST_NUMBER}`)
}
0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago