diff --git a/.github/workflows/register-preview-url.yml b/.github/workflows/register-preview-url.yml index 5271bff2d7..f4f4dc0921 100644 --- a/.github/workflows/register-preview-url.yml +++ b/.github/workflows/register-preview-url.yml @@ -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: | diff --git a/scripts/add-preview-url-to-cloud-idp.ts b/scripts/add-preview-url-to-cloud-idp.ts index 51f6a04258..9415aef52f 100644 --- a/scripts/add-preview-url-to-cloud-idp.ts +++ b/scripts/add-preview-url-to-cloud-idp.ts @@ -29,8 +29,18 @@ async function fetchDeploymentAlias(previewUrl: string): Promise { 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