From f445d0b956968f009f2dd128492467ce26838e13 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Wed, 9 Oct 2024 11:04:55 +0530 Subject: [PATCH] Store deployer lrn for each deployment --- packages/backend/src/entity/Deployment.ts | 3 ++ packages/backend/src/entity/Project.ts | 2 +- packages/backend/src/service.ts | 44 ++++++++++++------- .../components/projects/create/Configure.tsx | 2 +- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/packages/backend/src/entity/Deployment.ts b/packages/backend/src/entity/Deployment.ts index 39485ba5..a2719986 100644 --- a/packages/backend/src/entity/Deployment.ts +++ b/packages/backend/src/entity/Deployment.ts @@ -127,6 +127,9 @@ export class Deployment { @Column('simple-json', { nullable: true }) applicationDeploymentRemovalRecordData!: AppDeploymentRemovalRecordAttributes | null; + @Column('varchar') + deployerLrn!: string; + @Column({ enum: Environment }) diff --git a/packages/backend/src/entity/Project.ts b/packages/backend/src/entity/Project.ts index f4f14394..e877878a 100644 --- a/packages/backend/src/entity/Project.ts +++ b/packages/backend/src/entity/Project.ts @@ -50,7 +50,7 @@ export class Project { auctionId?: string | null; @Column({ type: 'simple-array', nullable: true }) - deployerLrn?: string[] | null; + deployerLrn!: string[] | null; // TODO: Compute template & framework in import repository @Column('varchar', { nullable: true }) diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 266e6106..58e1cb91 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -553,7 +553,7 @@ export class Service { domain: prodBranchDomains[0], commitHash: oldDeployment.commitHash, commitMessage: oldDeployment.commitMessage, - }); + }, oldDeployment.deployerLrn); return newDeployment; } @@ -562,7 +562,7 @@ export class Service { userId: string, octokit: Octokit, data: DeepPartial, - lrn?: string + lrn: string ): Promise { assert(data.project?.repository, 'Project repository not found'); log( @@ -629,6 +629,7 @@ export class Service { createdBy: Object.assign(new User(), { id: userId, }), + deployerLrn: lrn, }); log( @@ -887,7 +888,7 @@ export class Service { const { applicationDeploymentAuctionId } = await this.registry.createApplicationDeploymentAuction(repo, octokit, auctionData!, deploymentData); await this.updateProject(project.id, { auctionId: applicationDeploymentAuctionId }) } else { - await this.createDeployment(user.id, octokit, deploymentData, lrn); + await this.createDeployment(user.id, octokit, deploymentData, lrn!); } await this.createRepoHook(octokit, project); @@ -959,19 +960,30 @@ export class Service { branch, }); - // Create deployment with branch and latest commit in GitHub data - await this.createDeployment(project.ownerId, octokit, { - project, - branch, - environment: - project.prodBranch === branch - ? Environment.Production - : Environment.Preview, - domain, - commitHash: headCommit.id, - commitMessage: headCommit.message, - }); + const deployers = project.deployerLrn; + if (!deployers) { + return; + } + + for (const deployer of deployers) { + // Create deployment with branch and latest commit in GitHub data + await this.createDeployment(project.ownerId, octokit, + { + project, + branch, + environment: + project.prodBranch === branch + ? Environment.Production + : Environment.Preview, + domain, + commitHash: headCommit.id, + commitMessage: headCommit.message, + }, + deployer + ); + } } + } async updateProject( @@ -1028,7 +1040,7 @@ export class Service { domain: oldDeployment.domain, commitHash: oldDeployment.commitHash, commitMessage: oldDeployment.commitMessage, - }); + }, oldDeployment.deployerLrn); return newDeployment; } diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index 1411c5df..244b814c 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -190,7 +190,7 @@ const Configure = () => { ) } > - {isLoading ? 'Deploying' : 'Deploy'} + {isLoading ? 'Deploying repo' : 'Deploy repo'}