avoid building a custom image

pull/365/head
Paul Pacheco 2022-03-30 07:52:50 -05:00
parent 9a40b8903e
commit 82e0c4af51
4 changed files with 21 additions and 12 deletions

16
dist/index.js vendored
View File

@ -64,8 +64,8 @@ function runMain() {
mac_builder_1.default.run(actionFolder, workspace, buildParameters);
}
else {
builtImage = yield model_1.Docker.build({ path: actionFolder, dockerfile, baseImage });
yield model_1.Docker.run(builtImage, Object.assign({ workspace }, buildParameters));
//builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
yield model_1.Docker.run(baseImage, Object.assign({ workspace, actionFolder }, buildParameters));
}
}
// Set output
@ -3307,18 +3307,19 @@ class Docker {
}
static run(image, parameters, silent = false) {
return __awaiter(this, void 0, void 0, function* () {
const { workspace, unitySerial, runnerTempPath, sshAgent } = parameters;
const baseOsSpecificArguments = this.getBaseOsSpecificArguments(process.platform, workspace, unitySerial, runnerTempPath, sshAgent);
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}`;
${image} -- \
/usr/bin/bash -c /entrypoint.sh`;
yield exec_1.exec(runCommand, undefined, { silent });
});
}
static getBaseOsSpecificArguments(baseOs, workspace, unitySerial, runnerTemporaryPath, sshAgent) {
static getBaseOsSpecificArguments(baseOs, workspace, actionFolder, unitySerial, runnerTemporaryPath, sshAgent) {
switch (baseOs) {
case 'linux': {
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
@ -3333,6 +3334,9 @@ class Docker {
--volume "${githubHome}":"/root:z" \
--volume "${githubWorkflow}":"/github/workflow:z" \
--volume "${workspace}":"/github/workspace:z" \
--volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \
--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' : ''}`;
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -27,8 +27,8 @@ async function runMain() {
if (process.platform === 'darwin') {
MacBuilder.run(actionFolder, workspace, buildParameters);
} else {
builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
await Docker.run(builtImage, { workspace, ...buildParameters });
//builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
await Docker.run(baseImage, { workspace, actionFolder, ...buildParameters });
}
}

View File

@ -21,11 +21,12 @@ class Docker {
}
static async run(image, parameters, silent = false) {
const { workspace, unitySerial, runnerTempPath, sshAgent } = parameters;
const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters;
const baseOsSpecificArguments = this.getBaseOsSpecificArguments(
process.platform,
workspace,
actionFolder,
unitySerial,
runnerTempPath,
sshAgent,
@ -36,12 +37,13 @@ class Docker {
--rm \
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
${baseOsSpecificArguments} \
${image}`;
${image} -- \
/usr/bin/bash -c /entrypoint.sh`;
await exec(runCommand, undefined, { silent });
}
static getBaseOsSpecificArguments(baseOs, workspace, unitySerial, runnerTemporaryPath, sshAgent): string {
static getBaseOsSpecificArguments(baseOs, workspace, actionFolder, unitySerial, runnerTemporaryPath, sshAgent): string {
switch (baseOs) {
case 'linux': {
const githubHome = path.join(runnerTemporaryPath, '_github_home');
@ -55,6 +57,9 @@ class Docker {
--volume "${githubHome}":"/root:z" \
--volume "${githubWorkflow}":"/github/workflow:z" \
--volume "${workspace}":"/github/workspace:z" \
--volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \
--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' : ''}`;
}