Use oldest custom domain in deployment requests
This commit is contained in:
parent
5d9c965f54
commit
82c4b71694
@ -603,6 +603,25 @@ export class Database {
|
||||
return domains;
|
||||
}
|
||||
|
||||
async getOldestDomainByProjectId(
|
||||
projectId: string,
|
||||
): Promise<Domain[]> {
|
||||
const domainRepository = this.dataSource.getRepository(Domain);
|
||||
|
||||
const domains = await domainRepository.find({
|
||||
where: {
|
||||
project: {
|
||||
id: projectId
|
||||
},
|
||||
},
|
||||
order: {
|
||||
createdAt: 'ASC'
|
||||
}
|
||||
});
|
||||
|
||||
return domains;
|
||||
}
|
||||
|
||||
async getLatestDNSDataByProjectId(
|
||||
projectId: string,
|
||||
): Promise<DNSRecordAttributes | null> {
|
||||
|
@ -663,6 +663,14 @@ export class Service {
|
||||
const address = await this.getAddress();
|
||||
const { repo, repoUrl } = await getRepoDetails(octokit, data.project.repository, data.commitHash);
|
||||
const environmentVariablesObj = await this.getEnvVariables(data.project!.id!);
|
||||
|
||||
// If a custom domain is present then use that as the DNS in the deployment request
|
||||
const domain = await this.db.getOldestDomainByProjectId(data.projectId!);
|
||||
let dns: string | undefined = undefined;
|
||||
if (domain) {
|
||||
dns = domain[0].name;
|
||||
}
|
||||
|
||||
// To set project DNS
|
||||
if (data.environment === Environment.Production) {
|
||||
// On deleting deployment later, project DNS deployment is also deleted
|
||||
@ -690,7 +698,7 @@ export class Service {
|
||||
lrn: deployer!.deployerLrn!,
|
||||
apiUrl: deployer!.deployerApiUrl!,
|
||||
environmentVariables: environmentVariablesObj,
|
||||
dns: `${newDeployment.project.name}-${newDeployment.id}`,
|
||||
dns: dns || `${newDeployment.project.name}-${newDeployment.id}`,
|
||||
payment: data.project.txHash,
|
||||
auctionId: data.project.auctionId,
|
||||
requesterAddress: address,
|
||||
|
Loading…
Reference in New Issue
Block a user