Integrate SP auctions for app deployment #2

Merged
nabarun merged 42 commits from ng-integrate-auction into main 2024-10-18 12:37:01 +00:00
2 changed files with 104 additions and 89 deletions
Showing only changes of commit f67dbd0ff3 - Show all commits

View File

@ -269,7 +269,7 @@ export class Registry {
appName: string,
repository: string,
auctionId?: string,
lrn?: string,
lrn: string,
environmentVariables: { [key: string]: string },
dns: string,
}): Promise<{
@ -304,7 +304,7 @@ export class Registry {
repository: data.repository,
repository_ref: data.deployment.commitHash
}),
...(data.lrn && { deployer: data.lrn }),
deployer: data.lrn,
...(data.auctionId && { auction: data.auctionId }),
};

View File

@ -287,7 +287,15 @@ export class Service {
);
for (const project of projectsToBedeployed) {
await this.createDeploymentFromAuction(project);
const deployerLrns = await this.registry.getAuctionWinners(project!.auctionId!);
// Update project with deployer LRNs
await this.db.updateProjectById(project.id!, {
deployerLrn: deployerLrns
})
for (const deployer of deployerLrns) {
await this.createDeploymentFromAuction(project, deployer);
}
}
}
@ -660,6 +668,7 @@ export class Service {
repository: repoUrl,
environmentVariables: environmentVariablesObj,
dns: `${newDeployment.project.name}`,
lrn
});
}
@ -688,13 +697,8 @@ export class Service {
async createDeploymentFromAuction(
project: DeepPartial<Project>,
) {
// Update project with deployer LRNs
const deployerLrns = await this.registry.getAuctionWinners(project!.auctionId!);
await this.db.updateProjectById(project.id!, {
deployerLrn: deployerLrns
})
deployer: string
): Promise<Deployment> {
const octokit = await this.getOctokit(project.ownerId!);
const [owner, repo] = project.repository!.split('/');
@ -719,7 +723,6 @@ export class Service {
const applicationRecordId = record.id;
const applicationRecordData = record.attributes;
for (const deployer of deployerLrns) {
// Create deployment with prod branch and latest commit
const deploymentData = {
project,
@ -743,6 +746,7 @@ export class Service {
createdBy: Object.assign(new User(), {
id: project.ownerId!,
}),
deployerLrn: deployer
});
log(
@ -773,6 +777,7 @@ export class Service {
repository: repoUrl,
environmentVariables: environmentVariablesObj,
dns: `${newDeployment.project.name}`,
lrn
});
}
@ -792,7 +797,8 @@ export class Service {
applicationDeploymentRequestId,
applicationDeploymentRequestData,
});
}
return newDeployment;
}
async addProjectFromTemplate(
@ -1032,7 +1038,13 @@ export class Service {
const octokit = await this.getOctokit(user.id);
const newDeployment = await this.createDeployment(user.id, octokit, {
let newDeployment: Deployment;
if (oldDeployment.project.auctionId) {
newDeployment = await this.createDeploymentFromAuction(oldDeployment.project, oldDeployment.deployerLrn);
} else {
newDeployment = await this.createDeployment(user.id, octokit,
{
project: oldDeployment.project,
// TODO: Put isCurrent field in project
branch: oldDeployment.branch,
@ -1040,7 +1052,10 @@ export class Service {
domain: oldDeployment.domain,
commitHash: oldDeployment.commitHash,
commitMessage: oldDeployment.commitMessage,
}, oldDeployment.deployerLrn);
},
oldDeployment.deployerLrn
);
}
return newDeployment;
}