File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change
1
+ # This workflow enables HashiCorp Oauth on Vercel preview deployments.
1
2
name : Register Preview URL with CloudIDP
2
3
3
4
on :
4
5
deployment_status :
5
-
6
+ # workflow_dispatch is here for supporting manual iteration
7
+ workflow_dispatch :
8
+ inputs :
9
+ preview_url :
10
+ description : ' A Vercel preview url. Only used during manual runs'
11
+ required : true
6
12
jobs :
7
13
on-deploy :
8
14
runs-on : ubuntu-latest
26
32
- name : Add Preview URL to CloudIDP
27
33
run : npx hc-tools ./scripts/add-preview-url-to-cloud-idp.ts
28
34
env :
35
+ # parameters
36
+ PREVIEW_URL : ${{ inputs.preview_url || github.event.deployment_status.target_url }}
37
+ # secrets
29
38
CLOUD_IDP_DEPLOYMENT_PREVIEW_PRIVATE_KEY : ${{ secrets.CLOUD_IDP_DEPLOYMENT_PREVIEW_PRIVATE_KEY }}
30
- PREVIEW_URL : ${{ github.event.deployment_status.target_url }}
31
39
FLOW_IDP_DEPLOYMENT_READY_URL : ${{ secrets.FLOW_IDP_DEPLOYMENT_READY_URL }}
32
40
VERCEL_API_TOKEN : ${{ secrets.VERCEL_API_TOKEN }}
33
41
VERCEL_TEAM_ID : ${{ secrets.VERCEL_TEAM_ID }}
Original file line number Diff line number Diff line change @@ -11,21 +11,26 @@ const fetch = createFetch()
11
11
const vercelApiToken = process . env . VERCEL_API_TOKEN
12
12
const vercelTeamId = process . env . VERCEL_TEAM_ID
13
13
14
+ // For Vercel API docs
15
+ // see https://vercel.com/docs/rest-api/endpoints#get-a-deployment-by-id-or-url
16
+
14
17
/** A helper to fetch Vercel Deployment Aliases from Vercel Deploy Preview URLs */
15
18
async function fetchDeploymentAlias ( previewUrl : string ) : Promise < string [ ] > {
19
+ console . log ( 'fetchDeploymentAlias' , previewUrl )
20
+
16
21
const previewHostname = new URL ( previewUrl ) . hostname
17
22
const url = new URL (
18
23
`v13/deployments/${ previewHostname } ` ,
19
24
'https://api.vercel.com'
20
25
)
21
26
22
27
url . searchParams . set ( 'teamId' , vercelTeamId )
23
- url . searchParams . set ( 'withAutomaticAliases' , '1' )
24
28
25
29
const headers = { Authorization : `Bearer ${ vercelApiToken } ` }
26
30
27
31
const res = await fetch ( url . toString ( ) , { headers } )
28
32
const data = await res . json ( )
33
+ console . log ( data )
29
34
30
35
// NOTE: returned aliases only contain hostname, and no scheme
31
36
// Scheme will need to be prepended before being passed in the
You can’t perform that action at this time.
0 commit comments