({
applicationId,
titleLog = "Preview Deployment",
descriptionLog = "",
previewDeploymentId,
}: {
applicationId: string;
titleLog: string;
descriptionLog: string;
previewDeploymentId: string;
})
| 346 | }; |
| 347 | |
| 348 | export const deployPreviewApplication = async ({ |
| 349 | applicationId, |
| 350 | titleLog = "Preview Deployment", |
| 351 | descriptionLog = "", |
| 352 | previewDeploymentId, |
| 353 | }: { |
| 354 | applicationId: string; |
| 355 | titleLog: string; |
| 356 | descriptionLog: string; |
| 357 | previewDeploymentId: string; |
| 358 | }) => { |
| 359 | const application = await findApplicationById(applicationId); |
| 360 | |
| 361 | const deployment = await createDeploymentPreview({ |
| 362 | title: titleLog, |
| 363 | description: descriptionLog, |
| 364 | previewDeploymentId: previewDeploymentId, |
| 365 | }); |
| 366 | |
| 367 | const previewDeployment = |
| 368 | await findPreviewDeploymentById(previewDeploymentId); |
| 369 | |
| 370 | await updatePreviewDeployment(previewDeploymentId, { |
| 371 | createdAt: new Date().toISOString(), |
| 372 | }); |
| 373 | |
| 374 | const previewDomain = getDomainHost(previewDeployment?.domain as Domain); |
| 375 | const issueParams = { |
| 376 | owner: application?.owner || "", |
| 377 | repository: application?.repository || "", |
| 378 | issue_number: previewDeployment.pullRequestNumber, |
| 379 | comment_id: Number.parseInt(previewDeployment.pullRequestCommentId), |
| 380 | githubId: application?.githubId || "", |
| 381 | }; |
| 382 | try { |
| 383 | const commentExists = await issueCommentExists({ |
| 384 | ...issueParams, |
| 385 | }); |
| 386 | if (!commentExists) { |
| 387 | const result = await createPreviewDeploymentComment({ |
| 388 | ...issueParams, |
| 389 | previewDomain, |
| 390 | appName: previewDeployment.appName, |
| 391 | githubId: application?.githubId || "", |
| 392 | previewDeploymentId, |
| 393 | }); |
| 394 | |
| 395 | if (!result) { |
| 396 | throw new TRPCError({ |
| 397 | code: "NOT_FOUND", |
| 398 | message: "Pull request comment not found", |
| 399 | }); |
| 400 | } |
| 401 | |
| 402 | issueParams.comment_id = Number.parseInt(result?.pullRequestCommentId); |
| 403 | } |
| 404 | const buildingComment = getIssueComment( |
| 405 | application.name, |
no test coverage detected