mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00

* Update cloud-runner-aws-pipeline.yml * Update cloud-runner-k8s-pipeline.yml * yarn build * yarn build * correct branch ref * correct branch ref passed to target repo * Create k8s-tests.yml * Delete k8s-tests.yml * correct branch ref passed to target repo * correct branch ref passed to target repo
66 lines
2.8 KiB
TypeScript
66 lines
2.8 KiB
TypeScript
import path from 'path';
|
|
import { Input } from '../..';
|
|
import { CloudRunnerBuildCommandProcessor } from '../services/cloud-runner-build-command-process';
|
|
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';
|
|
import { StepInterface } from './step-interface';
|
|
|
|
export class SetupStep implements StepInterface {
|
|
async run(cloudRunnerStepState: CloudRunnerStepState) {
|
|
try {
|
|
return await SetupStep.downloadRepository(
|
|
cloudRunnerStepState.image,
|
|
cloudRunnerStepState.environment,
|
|
cloudRunnerStepState.secrets,
|
|
);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
private static getCloudRunnerBranch() {
|
|
return process.env.CLOUD_RUNNER_BRANCH?.includes('/')
|
|
? process.env.CLOUD_RUNNER_BRANCH.split('/').reverse()[0]
|
|
: process.env.CLOUD_RUNNER_BRANCH;
|
|
}
|
|
|
|
private static async downloadRepository(
|
|
image: string,
|
|
environmentVariables: CloudRunnerEnvironmentVariable[],
|
|
secrets: CloudRunnerSecret[],
|
|
) {
|
|
try {
|
|
CloudRunnerLogger.log(` `);
|
|
CloudRunnerLogger.logLine('Starting step 1/2 (setup game files from repository)');
|
|
const hooks = CloudRunnerBuildCommandProcessor.getHooks().filter((x) => x.step.includes(`setup`));
|
|
return await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
|
CloudRunnerState.buildParams.buildGuid,
|
|
image,
|
|
`apk update -q
|
|
apk add git-lfs jq tree zip unzip nodejs -q
|
|
${hooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '}
|
|
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
|
mkdir -p ${CloudRunnerState.builderPathFull.replace(/\\/g, `/`)}
|
|
git clone -q -b ${SetupStep.getCloudRunnerBranch()} ${
|
|
CloudRunnerState.unityBuilderRepoUrl
|
|
} "${CloudRunnerState.builderPathFull.replace(/\\/g, `/`)}"
|
|
${Input.cloudRunnerTests ? '' : '#'} tree ${CloudRunnerState.builderPathFull.replace(/\\/g, `/`)}
|
|
chmod +x ${path.join(CloudRunnerState.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)}
|
|
node ${path.join(CloudRunnerState.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)} -m remote-cli
|
|
${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}
|
|
`,
|
|
`/${CloudRunnerState.buildVolumeFolder}`,
|
|
`/${CloudRunnerState.buildVolumeFolder}/`,
|
|
environmentVariables,
|
|
secrets,
|
|
);
|
|
} catch (error) {
|
|
CloudRunnerLogger.logLine(`Failed download repository step 1/2`);
|
|
throw error;
|
|
}
|
|
}
|
|
}
|