({
applicationId,
titleLog = "Rebuild Preview Deployment",
descriptionLog = "",
previewDeploymentId,
}: {
applicationId: string;
titleLog: string;
descriptionLog: string;
previewDeploymentId: string;
})
| 466 | }; |
| 467 | |
| 468 | export const rebuildPreviewApplication = async ({ |
| 469 | applicationId, |
| 470 | titleLog = "Rebuild Preview Deployment", |
| 471 | descriptionLog = "", |
| 472 | previewDeploymentId, |
| 473 | }: { |
| 474 | applicationId: string; |
| 475 | titleLog: string; |
| 476 | descriptionLog: string; |
| 477 | previewDeploymentId: string; |
| 478 | }) => { |
| 479 | const application = await findApplicationById(applicationId); |
| 480 | const previewDeployment = |
| 481 | await findPreviewDeploymentById(previewDeploymentId); |
| 482 | |
| 483 | const deployment = await createDeploymentPreview({ |
| 484 | title: titleLog, |
| 485 | description: descriptionLog, |
| 486 | previewDeploymentId: previewDeploymentId, |
| 487 | }); |
| 488 | |
| 489 | const previewDomain = getDomainHost(previewDeployment?.domain as Domain); |
| 490 | const issueParams = { |
| 491 | owner: application?.owner || "", |
| 492 | repository: application?.repository || "", |
| 493 | issue_number: previewDeployment.pullRequestNumber, |
| 494 | comment_id: Number.parseInt(previewDeployment.pullRequestCommentId), |
| 495 | githubId: application?.githubId || "", |
| 496 | }; |
| 497 | |
| 498 | try { |
| 499 | const commentExists = await issueCommentExists({ |
| 500 | ...issueParams, |
| 501 | }); |
| 502 | if (!commentExists) { |
| 503 | const result = await createPreviewDeploymentComment({ |
| 504 | ...issueParams, |
| 505 | previewDomain, |
| 506 | appName: previewDeployment.appName, |
| 507 | githubId: application?.githubId || "", |
| 508 | previewDeploymentId, |
| 509 | }); |
| 510 | |
| 511 | if (!result) { |
| 512 | throw new TRPCError({ |
| 513 | code: "NOT_FOUND", |
| 514 | message: "Pull request comment not found", |
| 515 | }); |
| 516 | } |
| 517 | |
| 518 | issueParams.comment_id = Number.parseInt(result?.pullRequestCommentId); |
| 519 | } |
| 520 | |
| 521 | const buildingComment = getIssueComment( |
| 522 | application.name, |
| 523 | "running", |
| 524 | previewDomain, |
| 525 | ); |
no test coverage detected