Skip to content

Commit

Permalink
Merge branch 'new-gel-docs' into quickstart-next
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Feb 8, 2025
2 parents 1f67715 + 381feec commit 860f773
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions .github/scripts/docs/preview-deploy.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -29,15 +35,14 @@ module.exports = async ({ github, context }) => {
c.body?.startsWith(commentHeader)
);

let deploymentError = null;
let deployment;
try {
deployment = await vercelFetch("https://api.vercel.com/v13/deployments", {
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`,
Expand All @@ -46,6 +51,7 @@ module.exports = async ({ github, context }) => {

commentMessage += `\n🔄 Deploying docs preview for commit ${shortCommitSHA}:\n\n<https://${deployment.url}>`;
} catch (e) {
deploymentError = e;
commentMessage += `\n❌ Failed to deploy docs preview for commit ${shortCommitSHA}:\n\n\`\`\`\n${e.message}\n\`\`\``;
}

Expand All @@ -69,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);
Expand Down Expand Up @@ -106,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<https://${
deployment.url
}>\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) {
Expand Down

0 comments on commit 860f773

Please sign in to comment.