From df9985bc46fe7f0e6ef0c115afd4a7e5f572347e Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sat, 8 Feb 2025 12:11:47 +0000 Subject: [PATCH 1/2] Update docs site deployment branch --- .github/scripts/docs/preview-deploy.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/scripts/docs/preview-deploy.js b/.github/scripts/docs/preview-deploy.js index 4906c25f97b..b23c02128fa 100644 --- a/.github/scripts/docs/preview-deploy.js +++ b/.github/scripts/docs/preview-deploy.js @@ -1,3 +1,9 @@ +const DOCS_SITE_REPO = { + org: "edgedb", + repo: "edgedb.com", + ref: "new-new-docs", +}; + module.exports = async ({ github, context }) => { const { VERCEL_TOKEN, VERCEL_TEAM_ID } = process.env; @@ -35,9 +41,7 @@ module.exports = async ({ github, context }) => { name: "edgedb-docs", gitSource: { type: "github", - org: "edgedb", - repo: "edgedb.com", - ref: "docs-preview", + ...DOCS_SITE_REPO, }, projectSettings: { buildCommand: `EDGEDB_REPO_BRANCH=${prBranch} EDGEDB_REPO_SHA=${commitSHA} yarn vercel-build`, From 381feec12cfbb08a515e5728e550eab5536a0ed7 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sat, 8 Feb 2025 12:14:18 +0000 Subject: [PATCH 2/2] Return errors from script if deployment fails --- .github/scripts/docs/preview-deploy.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/scripts/docs/preview-deploy.js b/.github/scripts/docs/preview-deploy.js index b23c02128fa..27e8be7d29f 100644 --- a/.github/scripts/docs/preview-deploy.js +++ b/.github/scripts/docs/preview-deploy.js @@ -35,6 +35,7 @@ module.exports = async ({ github, context }) => { c.body?.startsWith(commentHeader) ); + let deploymentError = null; let deployment; try { deployment = await vercelFetch("https://api.vercel.com/v13/deployments", { @@ -50,6 +51,7 @@ module.exports = async ({ github, context }) => { commentMessage += `\nšŸ”„ Deploying docs preview for commit ${shortCommitSHA}:\n\n`; } catch (e) { + deploymentError = e; commentMessage += `\nāŒ Failed to deploy docs preview for commit ${shortCommitSHA}:\n\n\`\`\`\n${e.message}\n\`\`\``; } @@ -73,6 +75,10 @@ module.exports = async ({ github, context }) => { ).data; } + if (deploymentError) { + throw new Error(`Docs preview deployment failed: ${e.message}`); + } + let i = 0; while (i < 40) { await sleep(15_000); @@ -110,10 +116,25 @@ module.exports = async ({ github, context }) => { new Date() )})`, }); + if (status !== "READY") { + throw new Error( + `Docs preview deployment failed with status ${status}: https://${deployment.url}` + ); + } return; } } - throw new Error("timed out waiting for deployment status to succeed or fail"); + + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: updateComment.id, + body: `${commentHeader} +āŒ Timed out waiting for deployment status to succeed or fail for commit ${shortCommitSHA}:\n\n\n\n(Last updated: ${formatDatetime(new Date())})`, + }); + throw new Error("Timed out waiting for deployment status to succeed or fail"); }; async function vercelFetch(url, body) {