-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (49 loc) · 2.49 KB
/
vercel-deployment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Wait for Vercel Deployment
on:
workflow_call:
outputs:
vercel-deployment-url:
description: 'The vercel deployment url'
value: ${{ jobs.wait-for-vercel-deployment.outputs.vercel-deployment-url }}
secrets:
VERCEL_TOKEN:
required: true
VERCEL_PROJECT_ID:
required: true
VERCEL_TEAM_ID:
required: true
env:
VERCEL_FETCH_DEPLOYMENTS_API_ENDPOINT: https://api.vercel.com/v6/deployments
jobs:
wait-for-vercel-deployment:
name: Wait for current Vercel deployment to be ready
runs-on: ubuntu-latest
outputs:
vercel-deployment-url: ${{ steps.expose-vercel-deployment.outputs.vercel-deployment-url }}
steps:
- name: Sleep to wait for new deployment is created
run: sleep 10
- name: Resolving the latest deployment url from Vercel
run: |
apt update -y >/dev/null && apt install -y jq >/dev/null
echo "Fetching Vercel deployments using API endpoint: " $VERCEL_FETCH_DEPLOYMENTS_API_ENDPOINT
# Fetch all Vercel deployment from this project
API_ENDPOINT="${VERCEL_FETCH_DEPLOYMENTS_API_ENDPOINT}?projectId=${{ secrets.VERCEL_PROJECT_ID }}&teamId=${{ secrets.VERCEL_TEAM_ID }}"
ALL_VERCEL_DEPLOYMENTS=`curl -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}' $API_ENDPOINT`
echo "Vercel deployments: " $ALL_VERCEL_DEPLOYMENTS
# Parse the deployments (as json) to find the latest deployment url, while stripping the double quotes
VERCEL_DEPLOYMENT_URL=`echo $ALL_VERCEL_DEPLOYMENTS | jq '.deployments [0].url' | tr -d \"`
echo "VERCEL_DEPLOYMENT_URL=$VERCEL_DEPLOYMENT_URL" >> $GITHUB_ENV
- name: Wait for Vercel deployment to be ready
uses: UnlyEd/github-action-await-vercel@v2
id: await-vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
deployment-url: ${{ env.VERCEL_DEPLOYMENT_URL }} # Must only contain the domain name (no http prefix, etc.)
timeout: 240 # Wait for 4 mins before failing
- name: Expose Vercel deployment info
id: expose-vercel-deployment
run: echo "vercel-deployment-url=${{ env.VERCEL_DEPLOYMENT_URL }}" >> $GITHUB_OUTPUT
- name: Display Vercel deployment status
run: 'echo The deployment at ${{ fromJson(steps.await-vercel.outputs.deploymentDetails).url }} is ${{ fromJson(steps.await-vercel.outputs.deploymentDetails).readyState }}'