Pass auction id in deployment requests
This commit is contained in:
parent
22fb9323d7
commit
f67dbd0ff3
@ -269,7 +269,7 @@ export class Registry {
|
|||||||
appName: string,
|
appName: string,
|
||||||
repository: string,
|
repository: string,
|
||||||
auctionId?: string,
|
auctionId?: string,
|
||||||
lrn?: string,
|
lrn: string,
|
||||||
environmentVariables: { [key: string]: string },
|
environmentVariables: { [key: string]: string },
|
||||||
dns: string,
|
dns: string,
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
@ -304,7 +304,7 @@ export class Registry {
|
|||||||
repository: data.repository,
|
repository: data.repository,
|
||||||
repository_ref: data.deployment.commitHash
|
repository_ref: data.deployment.commitHash
|
||||||
}),
|
}),
|
||||||
...(data.lrn && { deployer: data.lrn }),
|
deployer: data.lrn,
|
||||||
...(data.auctionId && { auction: data.auctionId }),
|
...(data.auctionId && { auction: data.auctionId }),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -287,7 +287,15 @@ export class Service {
|
|||||||
);
|
);
|
||||||
|
|
||||||
for (const project of projectsToBedeployed) {
|
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,
|
repository: repoUrl,
|
||||||
environmentVariables: environmentVariablesObj,
|
environmentVariables: environmentVariablesObj,
|
||||||
dns: `${newDeployment.project.name}`,
|
dns: `${newDeployment.project.name}`,
|
||||||
|
lrn
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,13 +697,8 @@ export class Service {
|
|||||||
|
|
||||||
async createDeploymentFromAuction(
|
async createDeploymentFromAuction(
|
||||||
project: DeepPartial<Project>,
|
project: DeepPartial<Project>,
|
||||||
) {
|
deployer: string
|
||||||
// Update project with deployer LRNs
|
): Promise<Deployment> {
|
||||||
const deployerLrns = await this.registry.getAuctionWinners(project!.auctionId!);
|
|
||||||
await this.db.updateProjectById(project.id!, {
|
|
||||||
deployerLrn: deployerLrns
|
|
||||||
})
|
|
||||||
|
|
||||||
const octokit = await this.getOctokit(project.ownerId!);
|
const octokit = await this.getOctokit(project.ownerId!);
|
||||||
const [owner, repo] = project.repository!.split('/');
|
const [owner, repo] = project.repository!.split('/');
|
||||||
|
|
||||||
@ -719,7 +723,6 @@ export class Service {
|
|||||||
const applicationRecordId = record.id;
|
const applicationRecordId = record.id;
|
||||||
const applicationRecordData = record.attributes;
|
const applicationRecordData = record.attributes;
|
||||||
|
|
||||||
for (const deployer of deployerLrns) {
|
|
||||||
// Create deployment with prod branch and latest commit
|
// Create deployment with prod branch and latest commit
|
||||||
const deploymentData = {
|
const deploymentData = {
|
||||||
project,
|
project,
|
||||||
@ -743,6 +746,7 @@ export class Service {
|
|||||||
createdBy: Object.assign(new User(), {
|
createdBy: Object.assign(new User(), {
|
||||||
id: project.ownerId!,
|
id: project.ownerId!,
|
||||||
}),
|
}),
|
||||||
|
deployerLrn: deployer
|
||||||
});
|
});
|
||||||
|
|
||||||
log(
|
log(
|
||||||
@ -773,6 +777,7 @@ export class Service {
|
|||||||
repository: repoUrl,
|
repository: repoUrl,
|
||||||
environmentVariables: environmentVariablesObj,
|
environmentVariables: environmentVariablesObj,
|
||||||
dns: `${newDeployment.project.name}`,
|
dns: `${newDeployment.project.name}`,
|
||||||
|
lrn
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -792,7 +797,8 @@ export class Service {
|
|||||||
applicationDeploymentRequestId,
|
applicationDeploymentRequestId,
|
||||||
applicationDeploymentRequestData,
|
applicationDeploymentRequestData,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
return newDeployment;
|
||||||
}
|
}
|
||||||
|
|
||||||
async addProjectFromTemplate(
|
async addProjectFromTemplate(
|
||||||
@ -1032,7 +1038,13 @@ export class Service {
|
|||||||
|
|
||||||
const octokit = await this.getOctokit(user.id);
|
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,
|
project: oldDeployment.project,
|
||||||
// TODO: Put isCurrent field in project
|
// TODO: Put isCurrent field in project
|
||||||
branch: oldDeployment.branch,
|
branch: oldDeployment.branch,
|
||||||
@ -1040,7 +1052,10 @@ export class Service {
|
|||||||
domain: oldDeployment.domain,
|
domain: oldDeployment.domain,
|
||||||
commitHash: oldDeployment.commitHash,
|
commitHash: oldDeployment.commitHash,
|
||||||
commitMessage: oldDeployment.commitMessage,
|
commitMessage: oldDeployment.commitMessage,
|
||||||
}, oldDeployment.deployerLrn);
|
},
|
||||||
|
oldDeployment.deployerLrn
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return newDeployment;
|
return newDeployment;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user