support windows as well
parent
bab912e11e
commit
2b57369351
|
|
@ -3305,50 +3305,64 @@ class Docker {
|
||||||
}
|
}
|
||||||
static run(image, parameters, silent = false) {
|
static run(image, parameters, silent = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
let runCommand = '';
|
||||||
const baseOsSpecificArguments = this.getBaseOsSpecificArguments(process.platform, workspace, actionFolder, unitySerial, runnerTempPath, sshAgent);
|
switch (process.platform) {
|
||||||
const runCommand = `docker run \
|
case 'linux':
|
||||||
--workdir /github/workspace \
|
runCommand = this.getLinuxCommand(image, parameters);
|
||||||
--rm \
|
break;
|
||||||
${image_environment_factory_1.default.getEnvVarString(parameters)} \
|
case 'win32':
|
||||||
${baseOsSpecificArguments} \
|
runCommand = this.getWindowsCommand(image, parameters);
|
||||||
${image} \
|
}
|
||||||
/usr/bin/bash -c /entrypoint.sh`;
|
|
||||||
yield exec_1.exec(runCommand, undefined, { silent });
|
yield exec_1.exec(runCommand, undefined, { silent });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static getBaseOsSpecificArguments(baseOs, workspace, actionFolder, unitySerial, runnerTemporaryPath, sshAgent) {
|
static getLinuxCommand(image, parameters) {
|
||||||
switch (baseOs) {
|
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
||||||
case 'linux': {
|
const githubHome = path_1.default.join(runnerTempPath, '_github_home');
|
||||||
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
if (!fs_1.existsSync(githubHome))
|
||||||
if (!fs_1.existsSync(githubHome))
|
fs_1.mkdirSync(githubHome);
|
||||||
fs_1.mkdirSync(githubHome);
|
const githubWorkflow = path_1.default.join(runnerTempPath, '_github_workflow');
|
||||||
const githubWorkflow = path_1.default.join(runnerTemporaryPath, '_github_workflow');
|
if (!fs_1.existsSync(githubWorkflow))
|
||||||
if (!fs_1.existsSync(githubWorkflow))
|
fs_1.mkdirSync(githubWorkflow);
|
||||||
fs_1.mkdirSync(githubWorkflow);
|
return `docker run \
|
||||||
return `--env UNITY_SERIAL \
|
--workdir /github/workspace \
|
||||||
--env GITHUB_WORKSPACE=/github/workspace \
|
--rm \
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
${image_environment_factory_1.default.getEnvVarString(parameters)} \
|
||||||
--volume "${githubHome}":"/root:z" \
|
--env UNITY_SERIAL \
|
||||||
--volume "${githubWorkflow}":"/github/workflow:z" \
|
--env GITHUB_WORKSPACE=/github/workspace \
|
||||||
--volume "${workspace}":"/github/workspace:z" \
|
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||||
--volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \
|
--volume "${githubHome}":"/root:z" \
|
||||||
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
--volume "${githubWorkflow}":"/github/workflow:z" \
|
||||||
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
--volume "${workspace}":"/github/workspace:z" \
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
--volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
|
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
||||||
}
|
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
||||||
case 'win32':
|
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||||
return `--env UNITY_SERIAL="${unitySerial}" \
|
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||||
--env GITHUB_WORKSPACE=c:/github/workspace \
|
${image} \
|
||||||
--volume "${workspace}":"c:/github/workspace" \
|
-- \
|
||||||
--volume "c:/regkeys":"c:/regkeys" \
|
/bin/bash -c /entrypoint.sh`;
|
||||||
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
|
}
|
||||||
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
|
static getWindowsCommand(image, parameters) {
|
||||||
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio"`;
|
const { workspace, actionFolder, unitySerial } = parameters;
|
||||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
return `docker run \
|
||||||
}
|
--workdir /github/workspace \
|
||||||
return '';
|
--rm \
|
||||||
|
${image_environment_factory_1.default.getEnvVarString(parameters)} \
|
||||||
|
--env UNITY_SERIAL="${unitySerial}" \
|
||||||
|
--env GITHUB_WORKSPACE=c:/github/workspace \
|
||||||
|
--volume "${workspace}":"c:/github/workspace" \
|
||||||
|
--volume "c:/regkeys":"c:/regkeys" \
|
||||||
|
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
|
||||||
|
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
|
||||||
|
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \
|
||||||
|
--volume "${actionFolder}/default-build-script":"c:/UnityBuilderAction" \
|
||||||
|
--volume "${actionFolder}/platforms/ubuntu/steps":"c:/steps" \
|
||||||
|
--volume "${actionFolder}/platforms/windows/entrypoint.ps1":"c:/entrypoint.ps1" \
|
||||||
|
--volume "${actionFolder}/BlankProject":"c:/BlankProject" \
|
||||||
|
${image} \
|
||||||
|
-- \
|
||||||
|
powershell c:/entrypoint.ps1`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = Docker;
|
exports["default"] = Docker;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -21,66 +21,65 @@ class Docker {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async run(image, parameters, silent = false) {
|
static async run(image, parameters, silent = false) {
|
||||||
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
let runCommand = '';
|
||||||
|
switch (process.platform) {
|
||||||
const baseOsSpecificArguments = this.getBaseOsSpecificArguments(
|
case 'linux':
|
||||||
process.platform,
|
runCommand = this.getLinuxCommand(image, parameters);
|
||||||
workspace,
|
break;
|
||||||
actionFolder,
|
case 'win32':
|
||||||
unitySerial,
|
runCommand = this.getWindowsCommand(image, parameters);
|
||||||
runnerTempPath,
|
}
|
||||||
sshAgent,
|
|
||||||
);
|
|
||||||
|
|
||||||
const runCommand = `docker run \
|
|
||||||
--workdir /github/workspace \
|
|
||||||
--rm \
|
|
||||||
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
|
|
||||||
${baseOsSpecificArguments} \
|
|
||||||
${image} \
|
|
||||||
/usr/bin/bash -c /entrypoint.sh`;
|
|
||||||
|
|
||||||
await exec(runCommand, undefined, { silent });
|
await exec(runCommand, undefined, { silent });
|
||||||
}
|
}
|
||||||
|
|
||||||
static getBaseOsSpecificArguments(
|
static getLinuxCommand(image, parameters): string {
|
||||||
baseOs,
|
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
||||||
workspace,
|
|
||||||
actionFolder,
|
|
||||||
unitySerial,
|
|
||||||
runnerTemporaryPath,
|
|
||||||
sshAgent,
|
|
||||||
): string {
|
|
||||||
switch (baseOs) {
|
|
||||||
case 'linux': {
|
|
||||||
const githubHome = path.join(runnerTemporaryPath, '_github_home');
|
|
||||||
if (!existsSync(githubHome)) mkdirSync(githubHome);
|
|
||||||
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
|
|
||||||
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
|
|
||||||
|
|
||||||
return `--env UNITY_SERIAL \
|
const githubHome = path.join(runnerTempPath, '_github_home');
|
||||||
--env GITHUB_WORKSPACE=/github/workspace \
|
if (!existsSync(githubHome)) mkdirSync(githubHome);
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
const githubWorkflow = path.join(runnerTempPath, '_github_workflow');
|
||||||
--volume "${githubHome}":"/root:z" \
|
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
|
||||||
--volume "${githubWorkflow}":"/github/workflow:z" \
|
|
||||||
--volume "${workspace}":"/github/workspace:z" \
|
return `docker run \
|
||||||
--volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \
|
--workdir /github/workspace \
|
||||||
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
--rm \
|
||||||
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
--env UNITY_SERIAL \
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
|
--env GITHUB_WORKSPACE=/github/workspace \
|
||||||
}
|
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||||
case 'win32':
|
--volume "${githubHome}":"/root:z" \
|
||||||
return `--env UNITY_SERIAL="${unitySerial}" \
|
--volume "${githubWorkflow}":"/github/workflow:z" \
|
||||||
--env GITHUB_WORKSPACE=c:/github/workspace \
|
--volume "${workspace}":"/github/workspace:z" \
|
||||||
--volume "${workspace}":"c:/github/workspace" \
|
--volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \
|
||||||
--volume "c:/regkeys":"c:/regkeys" \
|
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
||||||
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
|
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
||||||
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
|
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||||
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio"`;
|
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
${image} \
|
||||||
}
|
-- \
|
||||||
return '';
|
/bin/bash -c /entrypoint.sh`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getWindowsCommand(image: any, parameters: any): string {
|
||||||
|
const { workspace, actionFolder, unitySerial } = parameters;
|
||||||
|
return `docker run \
|
||||||
|
--workdir /github/workspace \
|
||||||
|
--rm \
|
||||||
|
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
|
||||||
|
--env UNITY_SERIAL="${unitySerial}" \
|
||||||
|
--env GITHUB_WORKSPACE=c:/github/workspace \
|
||||||
|
--volume "${workspace}":"c:/github/workspace" \
|
||||||
|
--volume "c:/regkeys":"c:/regkeys" \
|
||||||
|
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
|
||||||
|
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
|
||||||
|
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \
|
||||||
|
--volume "${actionFolder}/default-build-script":"c:/UnityBuilderAction" \
|
||||||
|
--volume "${actionFolder}/platforms/ubuntu/steps":"c:/steps" \
|
||||||
|
--volume "${actionFolder}/platforms/windows/entrypoint.ps1":"c:/entrypoint.ps1" \
|
||||||
|
--volume "${actionFolder}/BlankProject":"c:/BlankProject" \
|
||||||
|
${image} \
|
||||||
|
-- \
|
||||||
|
powershell c:/entrypoint.ps1`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue