Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheyenbrock committed Jun 2, 2020
0 parents commit 120df91
Show file tree
Hide file tree
Showing 7 changed files with 2,407 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Vercel deployment URLs

This repository contains a GitHub action that uses the Vercel API to find the latest deployment for the current commit. It waits for the deployment to be done and then outputs the URL.

## Inputs

### `vercel-token`

**Required** A token to authenticate requests sent to the Vercel API. You can create one [here](https://vercel.com/account/tokens).

### `project-id`

**Required** The id of your Vercel project. Usually you can find it in the `.vercel/project.json` file inside your repository.

### `team-id`

If your Vercel project is owned by a team, you have to input the id of the team. It can also be found in the `.vercel/project.json` file. If you use the action for a personal Vercel project, don't use this input.

### `search-retries`

The number of retries if no deployment can be found for the current commit. There is a 5 second interval between tries. The default is `3`.

### `ready-retries`

The number of retries if the latest deployment found is not ready yet. There is a 30 second interval between tries. The default is `10`.

## Outputs

### `url`

The URL of the Vercel preview deployment in a `READY` state.

## Example usage

```yml
- name: Get deployment URL
id: deployment
uses: thomasheyenbrock/vercel-deployment-url@v1
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
project-id: ${{ secrets.VERCEL_PROjECT_ID }}
```
## Notes
- The action automatically uses the commit SHA that it runs on to find related Vercel deployments (using [deployment metadata](https://vercel.com/blog/deployment-metadata)). If there are multiple deployments for a single SHA the latest one is taken.
- This action will fail if...
- ...it can't find any Vercel deployment related to the current commit after the specified number of retries.
- ...the latest Vercel deployment for the current commit is not ready after the specified number of retries.
- ...the Vercel deployment fails.
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Get Vercel deployment"
description: "Gets the URL of the preview deployment on Vercel for the current commit"
inputs:
vercel-token:
description: "A token that allows access to the Vercel-API"
required: true
project-id:
description: "The identifier for your Vercel project"
required: true
team-id:
description: "The identifier for your Vercel team (leave blank for personal projects)"
required: false
search-retries:
description: "The number of times the action should try to find a deployment related to the current commit (5 seconds between searches)"
required: false
default: 3
ready-retries:
description: "The number of times the action should check if the latest deployment related to the current commit is ready (30 seconds between checks)"
required: false
default: 10
outputs:
url:
description: "The URL of the vercel preview deployment"
runs:
using: "node12"
main: "dist/index.js"
Loading

0 comments on commit 120df91

Please sign in to comment.