support windows as well
parent
bab912e11e
commit
2b57369351
|
|
@ -3305,28 +3305,30 @@ class Docker {
|
|||
}
|
||||
static run(image, parameters, silent = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
||||
const baseOsSpecificArguments = this.getBaseOsSpecificArguments(process.platform, workspace, actionFolder, unitySerial, runnerTempPath, sshAgent);
|
||||
const runCommand = `docker run \
|
||||
--workdir /github/workspace \
|
||||
--rm \
|
||||
${image_environment_factory_1.default.getEnvVarString(parameters)} \
|
||||
${baseOsSpecificArguments} \
|
||||
${image} \
|
||||
/usr/bin/bash -c /entrypoint.sh`;
|
||||
let runCommand = '';
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
runCommand = this.getLinuxCommand(image, parameters);
|
||||
break;
|
||||
case 'win32':
|
||||
runCommand = this.getWindowsCommand(image, parameters);
|
||||
}
|
||||
yield exec_1.exec(runCommand, undefined, { silent });
|
||||
});
|
||||
}
|
||||
static getBaseOsSpecificArguments(baseOs, workspace, actionFolder, unitySerial, runnerTemporaryPath, sshAgent) {
|
||||
switch (baseOs) {
|
||||
case 'linux': {
|
||||
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
||||
static getLinuxCommand(image, parameters) {
|
||||
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
||||
const githubHome = path_1.default.join(runnerTempPath, '_github_home');
|
||||
if (!fs_1.existsSync(githubHome))
|
||||
fs_1.mkdirSync(githubHome);
|
||||
const githubWorkflow = path_1.default.join(runnerTemporaryPath, '_github_workflow');
|
||||
const githubWorkflow = path_1.default.join(runnerTempPath, '_github_workflow');
|
||||
if (!fs_1.existsSync(githubWorkflow))
|
||||
fs_1.mkdirSync(githubWorkflow);
|
||||
return `--env UNITY_SERIAL \
|
||||
return `docker run \
|
||||
--workdir /github/workspace \
|
||||
--rm \
|
||||
${image_environment_factory_1.default.getEnvVarString(parameters)} \
|
||||
--env UNITY_SERIAL \
|
||||
--env GITHUB_WORKSPACE=/github/workspace \
|
||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||
--volume "${githubHome}":"/root:z" \
|
||||
|
|
@ -3336,19 +3338,31 @@ class Docker {
|
|||
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
||||
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
|
||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||
${image} \
|
||||
-- \
|
||||
/bin/bash -c /entrypoint.sh`;
|
||||
}
|
||||
case 'win32':
|
||||
return `--env UNITY_SERIAL="${unitySerial}" \
|
||||
static getWindowsCommand(image, parameters) {
|
||||
const { workspace, actionFolder, unitySerial } = parameters;
|
||||
return `docker run \
|
||||
--workdir /github/workspace \
|
||||
--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"`;
|
||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
||||
}
|
||||
return '';
|
||||
--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;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -21,44 +21,30 @@ class Docker {
|
|||
}
|
||||
|
||||
static async run(image, parameters, silent = false) {
|
||||
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
||||
|
||||
const baseOsSpecificArguments = this.getBaseOsSpecificArguments(
|
||||
process.platform,
|
||||
workspace,
|
||||
actionFolder,
|
||||
unitySerial,
|
||||
runnerTempPath,
|
||||
sshAgent,
|
||||
);
|
||||
|
||||
const runCommand = `docker run \
|
||||
--workdir /github/workspace \
|
||||
--rm \
|
||||
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
|
||||
${baseOsSpecificArguments} \
|
||||
${image} \
|
||||
/usr/bin/bash -c /entrypoint.sh`;
|
||||
|
||||
let runCommand = '';
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
runCommand = this.getLinuxCommand(image, parameters);
|
||||
break;
|
||||
case 'win32':
|
||||
runCommand = this.getWindowsCommand(image, parameters);
|
||||
}
|
||||
await exec(runCommand, undefined, { silent });
|
||||
}
|
||||
|
||||
static getBaseOsSpecificArguments(
|
||||
baseOs,
|
||||
workspace,
|
||||
actionFolder,
|
||||
unitySerial,
|
||||
runnerTemporaryPath,
|
||||
sshAgent,
|
||||
): string {
|
||||
switch (baseOs) {
|
||||
case 'linux': {
|
||||
const githubHome = path.join(runnerTemporaryPath, '_github_home');
|
||||
static getLinuxCommand(image, parameters): string {
|
||||
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
|
||||
|
||||
const githubHome = path.join(runnerTempPath, '_github_home');
|
||||
if (!existsSync(githubHome)) mkdirSync(githubHome);
|
||||
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
|
||||
const githubWorkflow = path.join(runnerTempPath, '_github_workflow');
|
||||
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
|
||||
|
||||
return `--env UNITY_SERIAL \
|
||||
return `docker run \
|
||||
--workdir /github/workspace \
|
||||
--rm \
|
||||
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
|
||||
--env UNITY_SERIAL \
|
||||
--env GITHUB_WORKSPACE=/github/workspace \
|
||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||
--volume "${githubHome}":"/root:z" \
|
||||
|
|
@ -68,19 +54,32 @@ class Docker {
|
|||
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
||||
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
|
||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||
${image} \
|
||||
-- \
|
||||
/bin/bash -c /entrypoint.sh`;
|
||||
}
|
||||
case 'win32':
|
||||
return `--env UNITY_SERIAL="${unitySerial}" \
|
||||
|
||||
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"`;
|
||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
||||
}
|
||||
return '';
|
||||
--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