Display deployment build logs #8
@ -1,16 +1,16 @@
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
import { Entity, PrimaryColumn, Column } from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class Deployer {
|
||||
@PrimaryColumn()
|
||||
deployerId!: string;
|
||||
@PrimaryColumn('varchar')
|
||||
deployerId!: string;
|
||||
|
||||
@Column()
|
||||
deployerLrn!: string;
|
||||
@Column('varchar')
|
||||
deployerLrn!: string;
|
||||
|
||||
@Column()
|
||||
deployerApiUrl!: string;
|
||||
@Column('varchar')
|
||||
deployerApiUrl!: string;
|
||||
|
||||
@Column()
|
||||
baseDomain!: string;
|
||||
@Column('varchar')
|
||||
baseDomain!: string;
|
||||
}
|
||||
|
@ -140,9 +140,6 @@ export class Deployment {
|
||||
@Column('boolean', { default: false })
|
||||
isCurrent!: boolean;
|
||||
|
||||
@Column('varchar', { nullable: true })
|
||||
baseDomain!: string | null;
|
||||
|
||||
@Column({
|
||||
enum: DeploymentStatus
|
||||
})
|
||||
|
@ -117,7 +117,7 @@ export class Registry {
|
||||
this.registryConfig.privateKey,
|
||||
fee
|
||||
);
|
||||
log("Result: ", result);
|
||||
|
||||
log(`Published application record ${result.id}`);
|
||||
log('Application record data:', applicationRecord);
|
||||
|
||||
@ -302,13 +302,9 @@ export class Registry {
|
||||
const { winnerAddresses } = auctionResult;
|
||||
|
||||
for (const auctionWinner of winnerAddresses) {
|
||||
const records = await this.registry.queryRecords(
|
||||
{
|
||||
paymentAddress: auctionWinner,
|
||||
type: WEBAPP_DEPLOYER_RECORD_TYPE,
|
||||
},
|
||||
true
|
||||
);
|
||||
const records = await this.getDeployerRecordsByFilter({
|
||||
paymentAddress: auctionWinner,
|
||||
});
|
||||
|
||||
for (const record of records) {
|
||||
if (record.id) {
|
||||
@ -361,6 +357,19 @@ export class Registry {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch WebappDeployer Records by filter
|
||||
*/
|
||||
async getDeployerRecordsByFilter(filter: { [key: string]: any }): Promise<DeployerRecord[]> {
|
||||
return this.registry.queryRecords(
|
||||
{
|
||||
type: WEBAPP_DEPLOYER_RECORD_TYPE,
|
||||
...filter
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch ApplicationDeploymentRecords by filter
|
||||
*/
|
||||
@ -441,8 +450,8 @@ export class Registry {
|
||||
const auctions = await this.registry.getAuctionsByIds(auctionIds);
|
||||
|
||||
const completedAuctions = auctions
|
||||
.filter((auction: { id: string, status: string }) => auction.status === 'completed')
|
||||
.map((auction: { id: string, status: string }) => auction.id);
|
||||
.filter((auction: { id: string, status: string }) => auction.status === 'completed')
|
||||
.map((auction: { id: string, status: string }) => auction.id);
|
||||
|
||||
return completedAuctions;
|
||||
}
|
||||
|
@ -176,6 +176,7 @@ export class Service {
|
||||
})),
|
||||
relations: {
|
||||
deployer: true,
|
||||
project: true,
|
||||
},
|
||||
order: {
|
||||
createdAt: 'DESC',
|
||||
@ -194,17 +195,19 @@ export class Service {
|
||||
const deploymentUpdatePromises = records.map(async (record) => {
|
||||
const deployment = recordToDeploymentsMap[record.attributes.request];
|
||||
|
||||
const parts = record.attributes.url.replace('https://', '').split('.');
|
||||
const baseDomain = parts.slice(1).join('.');
|
||||
if (!deployment.project) {
|
||||
log(`Project ${deployment.projectId} not found`);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
deployment.applicationDeploymentRecordId = record.id;
|
||||
deployment.applicationDeploymentRecordData = record.attributes;
|
||||
deployment.url = record.attributes.url;
|
||||
deployment.status = DeploymentStatus.Ready;
|
||||
deployment.isCurrent = deployment.environment === Environment.Production;
|
||||
|
||||
deployment.applicationDeploymentRecordId = record.id;
|
||||
deployment.applicationDeploymentRecordData = record.attributes;
|
||||
deployment.url = record.attributes.url;
|
||||
deployment.baseDomain = baseDomain;
|
||||
deployment.status = DeploymentStatus.Ready;
|
||||
deployment.isCurrent = deployment.environment === Environment.Production;
|
||||
|
||||
await this.db.updateDeploymentById(deployment.id, deployment);
|
||||
await this.db.updateDeploymentById(deployment.id, deployment);
|
||||
}
|
||||
|
||||
log(
|
||||
`Updated deployment ${deployment.id} with URL ${record.attributes.url}`,
|
||||
@ -314,27 +317,27 @@ export class Service {
|
||||
|
||||
for (const record of deployerRecords) {
|
||||
const deployerId = record.id;
|
||||
const deployerLrn = record.names[0]
|
||||
const deployerApiUrl = record.attributes.apiUrl;
|
||||
const deployerLrn = record.names[0];
|
||||
|
||||
deployerIds.push(deployerId);
|
||||
deployerLrns.push(deployerLrn);
|
||||
|
||||
const deployerApiUrl = record.attributes.apiUrl;
|
||||
const apiURL = new URL(deployerApiUrl);
|
||||
const baseDomain = apiURL.hostname.split('.').slice(-3).join('.');
|
||||
|
||||
const deployerData = {
|
||||
deployerId,
|
||||
deployerLrn,
|
||||
deployerApiUrl,
|
||||
baseDomain
|
||||
};
|
||||
|
||||
// Store the deployer in the DB
|
||||
// TODO: Update project with deployer
|
||||
await this.db.addDeployer(deployerData);
|
||||
}
|
||||
|
||||
// TODO:Update project with deployer LRNs
|
||||
// await this.db.updateProjectById(project.id!, {
|
||||
// deployerLrns
|
||||
// });
|
||||
|
||||
for (const deployer of deployerIds) {
|
||||
log(`Creating deployment for deployer LRN ${deployer}`);
|
||||
await this.createDeploymentFromAuction(project, deployer);
|
||||
@ -676,6 +679,19 @@ export class Service {
|
||||
applicationDeploymentRequestData,
|
||||
});
|
||||
|
||||
// const deployerRecord = await this.laconicRegistry.getDeployerRecordsByFilter({
|
||||
// name: deployerLrn,
|
||||
// });
|
||||
|
||||
// TODO: Store deployer data
|
||||
// newDeployment.project.deployers.push({
|
||||
// deployerId: deployerRecord[0].id,
|
||||
// deployerApiUrl: deployerRecord[0].attributes.apiUrl,
|
||||
// })
|
||||
// await this.updateProject(newDeployment.project.id, {
|
||||
// deployers:
|
||||
// });
|
||||
|
||||
return newDeployment;
|
||||
}
|
||||
|
||||
@ -886,7 +902,7 @@ export class Service {
|
||||
|
||||
if (auctionParams) {
|
||||
const { applicationDeploymentAuctionId } = await this.laconicRegistry.createApplicationDeploymentAuction(repo, octokit, auctionParams!, deploymentData);
|
||||
await this.updateProject(project.id, { auctionId: applicationDeploymentAuctionId })
|
||||
await this.updateProject(project.id, { auctionId: applicationDeploymentAuctionId });
|
||||
} else {
|
||||
await this.createDeployment(user.id, octokit, deploymentData);
|
||||
// await this.updateProject(project.id, { deployerLrns: [lrn!] })
|
||||
@ -966,22 +982,25 @@ export class Service {
|
||||
// return;
|
||||
// }
|
||||
|
||||
const deployers = project.deployers;
|
||||
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: deployer
|
||||
},
|
||||
);
|
||||
// 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: deployer
|
||||
},
|
||||
);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@ -1101,7 +1120,7 @@ export class Service {
|
||||
if (deployment && deployment.applicationDeploymentRecordId) {
|
||||
// If deployment is current, remove deployment for project subdomain as well
|
||||
if (deployment.isCurrent) {
|
||||
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.baseDomain}`;
|
||||
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.deployer.baseDomain}`;
|
||||
|
||||
// TODO: Store the latest DNS deployment record
|
||||
const deploymentRecords =
|
||||
|
@ -6,6 +6,14 @@ import {
|
||||
Environment,
|
||||
Project,
|
||||
} from 'gql-client';
|
||||
|
||||
import {
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
DialogContent,
|
||||
DialogActions,
|
||||
} from '@mui/material';
|
||||
|
||||
import { Avatar } from 'components/shared/Avatar';
|
||||
import {
|
||||
BranchStrokeIcon,
|
||||
@ -15,12 +23,6 @@ import {
|
||||
LoadingIcon,
|
||||
WarningIcon,
|
||||
} from 'components/shared/CustomIcon';
|
||||
import {
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
DialogContent,
|
||||
DialogActions,
|
||||
} from '@mui/material';
|
||||
import { Heading } from 'components/shared/Heading';
|
||||
import { OverflownText } from 'components/shared/OverflownText';
|
||||
import { Tag, TagTheme } from 'components/shared/Tag';
|
||||
@ -66,10 +68,10 @@ const DeploymentDetailsCard = ({
|
||||
prodBranchDomains,
|
||||
}: DeployDetailsCardProps) => {
|
||||
const [openDialog, setOpenDialog] = useState<boolean>(false);
|
||||
const handleOpenDialog = () => setOpenDialog(true);
|
||||
const handleCloseDialog = () => setOpenDialog(false);
|
||||
const [deploymentLogs, setDeploymentLogs] = useState<string>();
|
||||
|
||||
const handleOpenDialog = () => setOpenDialog(true);
|
||||
const handleCloseDialog = () => setOpenDialog(false);
|
||||
|
||||
const getIconByDeploymentStatus = (status: DeploymentStatus) => {
|
||||
if (
|
||||
@ -89,7 +91,7 @@ const DeploymentDetailsCard = ({
|
||||
|
||||
const fetchDeploymentLogs = useCallback(async () => {
|
||||
let url = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}`;
|
||||
const res = await fetch(url);
|
||||
const res = await fetch(url, { cache: 'no-store' });
|
||||
const logs = await res.text();
|
||||
setDeploymentLogs(logs);
|
||||
handleOpenDialog();
|
||||
|
Loading…
Reference in New Issue
Block a user