Skip to content

Commit

Permalink
chore(add-preview-url-to-cloud-idp.ts) friendly error (#2170)
Browse files Browse the repository at this point in the history
* add friendly error

* remove log
  • Loading branch information
thiskevinwang authored Sep 19, 2023
1 parent 48bc666 commit a0543d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/register-preview-url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
on-deploy:
runs-on: ubuntu-latest
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview'
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview' || github.event_name == 'workflow_dispatch'
steps:
- name: summary
run: |
Expand Down
12 changes: 11 additions & 1 deletion scripts/add-preview-url-to-cloud-idp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ async function fetchDeploymentAlias(previewUrl: string): Promise<string[]> {
const headers = { Authorization: `Bearer ${vercelApiToken}` }

const res = await fetch(url.toString(), { headers })

const data = await res.json()
console.log(data)
// Potential error:
// { error: { code: 'not_found', message: 'Deployment not found' } }
if (data?.error) {
console.log(data.error)
console.log(
`If the error.message is "Deployment not found", it is possible that the VERCEL_API_TOKEN GitHub repo secret is invalid.
Try rotating the value and re-running the action.`
)
throw new Error(data.error.message)
}

// NOTE: returned aliases only contain hostname, and no scheme
// Scheme will need to be prepended before being passed in the
Expand Down

1 comment on commit a0543d5

@vercel
Copy link

@vercel vercel bot commented on a0543d5 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.