assembled docker args
This commit is contained in:
parent
ae96735c11
commit
9d76cc2074
@ -72,7 +72,7 @@ inputs:
|
||||
description: ""
|
||||
default: "true"
|
||||
|
||||
push_tags:
|
||||
docker_push:
|
||||
description: ""
|
||||
default: "true"
|
||||
|
||||
|
||||
33
dist/index.js
vendored
33
dist/index.js
vendored
@ -62266,16 +62266,41 @@ function prepareDockerArgs(destinations) {
|
||||
return dockerArgs;
|
||||
}
|
||||
|
||||
function executeDockerBuild(dockerArgs) {
|
||||
function executeDockerBuild(dockerArgs, destinations) {
|
||||
const dockerArgsStr = dockerArgs.join(' ');
|
||||
const dockerSubCmd = core.getBooleanInput('use_buildx') ? 'buildx build' : 'build';
|
||||
const isBuildX = core.getBooleanInput('use_buildx');
|
||||
let dockerSubCmd = isBuildX ? 'buildx build' : 'build';
|
||||
if (core.getBooleanInput('docker_push')) {
|
||||
dockerSubCmd += ' --push';
|
||||
}
|
||||
const execStr = `docker ${dockerSubCmd} ${dockerArgsStr}`;
|
||||
console.log(`executing: ${execStr}`);
|
||||
|
||||
const proc = external_child_process_namespaceObject.spawnSync(`docker ${dockerSubCmd} ${dockerArgsStr}`, {
|
||||
const proc = external_child_process_namespaceObject.spawnSync(execStr, {
|
||||
shell: true,
|
||||
stdio: 'inherit',
|
||||
cwd : getDockerContextDir()
|
||||
});
|
||||
|
||||
// push for legacy builder
|
||||
// if (!isBuildX && core.getBooleanInput('docker_push')) {
|
||||
// destinations.forEach(dst => {
|
||||
// const pushProc = child_process.spawnSync('docker push ' + dst, {
|
||||
// shell: true,
|
||||
// stdio: 'inherit',
|
||||
// cwd : getDockerContextDir()
|
||||
// });
|
||||
// if (pushProc.status != null && pushProc.status > 0) {
|
||||
// throw new Error('docker push ' + dst + ' failed');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
if (proc.status != null && proc.status > 0) {
|
||||
throw new Error('docker build failed');
|
||||
}
|
||||
|
||||
console.log('proc error check'); // TODO remove debug
|
||||
if (proc.error != null) {
|
||||
throw proc.error;
|
||||
}
|
||||
@ -62324,7 +62349,7 @@ try {
|
||||
console.log('dockerArgs:', JSON.stringify(dockerArgs, null, 2));
|
||||
}
|
||||
|
||||
executeDockerBuild(dockerArgs);
|
||||
executeDockerBuild(dockerArgs, destinations);
|
||||
}
|
||||
catch (error) {
|
||||
console.log('Failed to build docker image', error);
|
||||
|
||||
@ -47,7 +47,7 @@ try {
|
||||
console.log('dockerArgs:', JSON.stringify(dockerArgs, null, 2));
|
||||
}
|
||||
|
||||
executeDockerBuild(dockerArgs);
|
||||
executeDockerBuild(dockerArgs, destinations);
|
||||
}
|
||||
catch (error) {
|
||||
console.log('Failed to build docker image', error);
|
||||
|
||||
31
src/lib.js
31
src/lib.js
@ -164,16 +164,41 @@ export function prepareDockerArgs(destinations) {
|
||||
return dockerArgs;
|
||||
}
|
||||
|
||||
export function executeDockerBuild(dockerArgs) {
|
||||
export function executeDockerBuild(dockerArgs, destinations) {
|
||||
const dockerArgsStr = dockerArgs.join(' ');
|
||||
const dockerSubCmd = core.getBooleanInput('use_buildx') ? 'buildx build' : 'build';
|
||||
const isBuildX = core.getBooleanInput('use_buildx');
|
||||
let dockerSubCmd = isBuildX ? 'buildx build' : 'build';
|
||||
if (core.getBooleanInput('docker_push')) {
|
||||
dockerSubCmd += ' --push';
|
||||
}
|
||||
const execStr = `docker ${dockerSubCmd} ${dockerArgsStr}`;
|
||||
console.log(`executing: ${execStr}`);
|
||||
|
||||
const proc = child_process.spawnSync(`docker ${dockerSubCmd} ${dockerArgsStr}`, {
|
||||
const proc = child_process.spawnSync(execStr, {
|
||||
shell: true,
|
||||
stdio: 'inherit',
|
||||
cwd : getDockerContextDir()
|
||||
});
|
||||
|
||||
// push for legacy builder
|
||||
// if (!isBuildX && core.getBooleanInput('docker_push')) {
|
||||
// destinations.forEach(dst => {
|
||||
// const pushProc = child_process.spawnSync('docker push ' + dst, {
|
||||
// shell: true,
|
||||
// stdio: 'inherit',
|
||||
// cwd : getDockerContextDir()
|
||||
// });
|
||||
// if (pushProc.status != null && pushProc.status > 0) {
|
||||
// throw new Error('docker push ' + dst + ' failed');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
if (proc.status != null && proc.status > 0) {
|
||||
throw new Error('docker build failed');
|
||||
}
|
||||
|
||||
console.log('proc error check'); // TODO remove debug
|
||||
if (proc.error != null) {
|
||||
throw proc.error;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user