unity-builder/src/model/cloud-runner/steps/download-repository-step.ts

65 lines
2.5 KiB
TypeScript
Raw Normal View History

import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
import CloudRunnerLogger from '../services/cloud-runner-logger';
import CloudRunnerSecret from '../services/cloud-runner-secret';
import { CloudRunnerState } from '../state/cloud-runner-state';
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
2021-10-06 01:19:42 +00:00
import { StepInterface } from './step-interface';
2021-10-06 01:19:42 +00:00
export class DownloadRepositoryStep implements StepInterface {
async run(cloudRunnerStepState: CloudRunnerStepState) {
2021-11-21 17:20:11 +00:00
try {
await DownloadRepositoryStep.downloadRepositoryStep(
cloudRunnerStepState.image,
cloudRunnerStepState.environment,
cloudRunnerStepState.secrets,
);
} catch (error) {
throw error;
}
}
private static async downloadRepositoryStep(
image: string,
environmentVariables: CloudRunnerEnvironmentVariable[],
secrets: CloudRunnerSecret[],
) {
2021-11-21 17:20:11 +00:00
try {
CloudRunnerLogger.logLine('Starting step 1/4 clone and restore cache');
2021-11-21 17:20:11 +00:00
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
CloudRunnerState.buildGuid,
image,
[
` printenv
apk update -q
apk add unzip zip git-lfs jq tree nodejs -q
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
# mkdir -p ${CloudRunnerState.buildPathFull}
mkdir -p ${CloudRunnerState.builderPathFull}
# mkdir -p ${CloudRunnerState.repoPathFull}
echo "${CloudRunnerState.cloneBuilderCommand}"
${CloudRunnerState.cloneBuilderCommand}
chmod +x ${CloudRunnerState.builderPathFull}/dist/index.js
node ${CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
# echo ' '
# echo 'Initializing source repository for cloning with caching of LFS files'
# ${CloudRunnerState.getCloneNoLFSCommand()}
# echo 'Source repository initialized'
# ls ${CloudRunnerState.projectPathFull}
# echo ' '
# echo 'Starting checks of cache for the Unity project Library and git LFS files'
# ${CloudRunnerState.getHandleCachingCommand()}
`,
2021-11-21 17:20:11 +00:00
],
`/${CloudRunnerState.buildVolumeFolder}`,
`/${CloudRunnerState.buildVolumeFolder}/`,
environmentVariables,
secrets,
);
} catch (error) {
CloudRunnerLogger.logLine(`ENV VARS ${JSON.stringify(environmentVariables)} SECRETS ${JSON.stringify(secrets)}`);
2021-11-21 17:20:11 +00:00
throw error;
}
}
}