2021-10-06 01:19:42 +00:00
|
|
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
|
|
|
|
import { CloudRunnerState } from '../state/cloud-runner-state';
|
|
|
|
|
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
|
|
|
|
|
import { BuildStep } from '../steps/build-step';
|
2021-12-24 01:58:22 +00:00
|
|
|
import { DownloadStep } from '../steps/download-step';
|
2021-10-06 01:19:42 +00:00
|
|
|
import { CustomWorkflow } from './custom-workflow';
|
|
|
|
|
import { WorkflowInterface } from './workflow-interface';
|
|
|
|
|
|
|
|
|
|
export class BuildAutomationWorkflow implements WorkflowInterface {
|
|
|
|
|
async run(cloudRunnerStepState: CloudRunnerStepState) {
|
2021-11-21 17:20:11 +00:00
|
|
|
try {
|
|
|
|
|
await BuildAutomationWorkflow.standardBuildAutomation(cloudRunnerStepState.image);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2021-10-06 01:19:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async standardBuildAutomation(baseImage: any) {
|
2021-11-21 17:20:11 +00:00
|
|
|
try {
|
|
|
|
|
CloudRunnerLogger.log(`Cloud Runner is running standard build automation`);
|
2021-10-06 01:19:42 +00:00
|
|
|
|
2021-12-24 01:58:22 +00:00
|
|
|
await new DownloadStep().run(
|
2021-11-21 17:20:11 +00:00
|
|
|
new CloudRunnerStepState(
|
|
|
|
|
'alpine/git',
|
|
|
|
|
CloudRunnerState.readBuildEnvironmentVariables(),
|
|
|
|
|
CloudRunnerState.defaultSecrets,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
CloudRunnerLogger.logWithTime('Download repository step time');
|
|
|
|
|
if (CloudRunnerState.buildParams.preBuildSteps !== '') {
|
|
|
|
|
await CustomWorkflow.runCustomJob(CloudRunnerState.buildParams.preBuildSteps);
|
|
|
|
|
}
|
|
|
|
|
CloudRunnerLogger.logWithTime('Pre build step(s) time');
|
2021-10-06 01:19:42 +00:00
|
|
|
|
2021-11-28 17:52:32 +00:00
|
|
|
await new BuildStep().run(
|
2021-11-21 17:20:11 +00:00
|
|
|
new CloudRunnerStepState(
|
|
|
|
|
baseImage,
|
|
|
|
|
CloudRunnerState.readBuildEnvironmentVariables(),
|
|
|
|
|
CloudRunnerState.defaultSecrets,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
CloudRunnerLogger.logWithTime('Build time');
|
2021-10-06 01:19:42 +00:00
|
|
|
|
2021-11-21 17:20:11 +00:00
|
|
|
if (CloudRunnerState.buildParams.postBuildSteps !== '') {
|
|
|
|
|
await CustomWorkflow.runCustomJob(CloudRunnerState.buildParams.postBuildSteps);
|
|
|
|
|
}
|
|
|
|
|
CloudRunnerLogger.logWithTime('Post build step(s) time');
|
2021-10-06 01:19:42 +00:00
|
|
|
|
2021-11-21 17:20:11 +00:00
|
|
|
CloudRunnerLogger.log(`Cloud Runner finished running standard build automation`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2021-10-06 01:19:42 +00:00
|
|
|
}
|
|
|
|
|
}
|