* Trigger a deployment for a project
(
provider: ProviderType,
projectId: string,
options: { preview: boolean; clearCache: boolean },
)
| 520 | * Trigger a deployment for a project |
| 521 | */ |
| 522 | async triggerDeployment( |
| 523 | provider: ProviderType, |
| 524 | projectId: string, |
| 525 | options: { preview: boolean; clearCache: boolean }, |
| 526 | ): Promise<DeploymentRun> { |
| 527 | const projectsService = new DeploymentProjectsService({ |
| 528 | accountability: this.accountability, |
| 529 | schema: this.schema, |
| 530 | }); |
| 531 | |
| 532 | const runsService = new DeploymentRunsService({ |
| 533 | accountability: this.accountability, |
| 534 | schema: this.schema, |
| 535 | }); |
| 536 | |
| 537 | const project = await projectsService.readOne(projectId); |
| 538 | const driver = await this.getDriver(provider); |
| 539 | |
| 540 | const result = await driver.triggerDeployment(project.external_id, { |
| 541 | preview: options.preview, |
| 542 | clearCache: options.clearCache, |
| 543 | }); |
| 544 | |
| 545 | const runId = await runsService.createOne({ |
| 546 | project: projectId, |
| 547 | external_id: result.deployment_id, |
| 548 | target: options.preview ? 'preview' : 'production', |
| 549 | status: result.status, |
| 550 | started_at: result.created_at.toISOString(), |
| 551 | ...(result.url ? { url: result.url } : {}), |
| 552 | }); |
| 553 | |
| 554 | return runsService.readOne(runId); |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Cancel a deployment run |
no test coverage detected