diff --git a/dist/index.js b/dist/index.js index c7cd19e..0ff5f1a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -62235,6 +62235,38 @@ function prepareDestinations(registries, tags) { return destinations; } +function prepareDockerArgs(destinations) { + let dockerArgs = (core.getInput('docker_args') ?? '').trim(); + if (dockerArgs.length > 0) { + dockerArgs = [dockerArgs]; + } + else { + dockerArgs = []; + } + + if(isNonEmptyStr(core.getInput("dockerfile"))) { + dockerArgs.unshift("--file " + core.getInput("dockerfile")) + } + + if(isNonEmptyStr(core.getInput("docker_context_dir"))) { + dockerArgs.unshift(core.getInput("docker_context_dir")) + } // TODO use runner workdir instead + + if(core.getBooleanInput("squash_layers")) { + dockerArgs.push("--squash") + } + + destinations.forEach(dest => { + dockerArgs.push("--tag " + dest) + }) + + if(isNonEmptyStr(core.getInput("additional_registry_destinations"))) { + dockerArgs.push(core.getInput("additional_registry_destinations")) + } + + return dockerArgs +} + ;// CONCATENATED MODULE: ./src/action.js @@ -62244,9 +62276,9 @@ function prepareDestinations(registries, tags) { try { const information = collect_all(true, false); - let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true; - console.log("debug=", debug) - debug=true + let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true; + console.log('debug=', debug); + debug = true; let targetRegistries = []; const repoStr = github.context.repo.owner + '/' + github.context.repo.repo; @@ -62272,6 +62304,11 @@ try { if (debug) { console.log('destinations:', JSON.stringify(destinations, null, 2)); } + + const dockerArgs = prepareDockerArgs(destinations); + if (debug) { + console.log('dockerArgs:', JSON.stringify(destinations, null, 2)); + } } catch (error) { console.log('Failed to build docker image', error); diff --git a/src/action.js b/src/action.js index ef09f44..ab14597 100644 --- a/src/action.js +++ b/src/action.js @@ -5,7 +5,7 @@ import { addCiRegistryAuth, collectTags, mergeArgRegistryAuthJson, - prepareDestinations, + prepareDestinations, prepareDockerArgs, processAdditionalRegistries, writeRegistryAuthJson } from './lib'; @@ -13,9 +13,9 @@ import { try { const information = action_information.collect_all(true, false); - let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true; - console.log("debug=", debug) - debug=true + let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true; + console.log('debug=', debug); + debug = true; let targetRegistries = []; const repoStr = github.context.repo.owner + '/' + github.context.repo.repo; @@ -41,6 +41,11 @@ try { if (debug) { console.log('destinations:', JSON.stringify(destinations, null, 2)); } + + const dockerArgs = prepareDockerArgs(destinations); + if (debug) { + console.log('dockerArgs:', JSON.stringify(destinations, null, 2)); + } } catch (error) { console.log('Failed to build docker image', error); diff --git a/src/lib.js b/src/lib.js index cf3f45c..7241d8e 100644 --- a/src/lib.js +++ b/src/lib.js @@ -134,3 +134,35 @@ export function prepareDestinations(registries, tags) { return destinations; } + +export function prepareDockerArgs(destinations) { + let dockerArgs = (core.getInput('docker_args') ?? '').trim(); + if (dockerArgs.length > 0) { + dockerArgs = [dockerArgs]; + } + else { + dockerArgs = []; + } + + if(isNonEmptyStr(core.getInput("dockerfile"))) { + dockerArgs.unshift("--file " + core.getInput("dockerfile")) + } + + if(isNonEmptyStr(core.getInput("docker_context_dir"))) { + dockerArgs.unshift(core.getInput("docker_context_dir")) + } // TODO use runner workdir instead + + if(core.getBooleanInput("squash_layers")) { + dockerArgs.push("--squash") + } + + destinations.forEach(dest => { + dockerArgs.push("--tag " + dest) + }) + + if(isNonEmptyStr(core.getInput("additional_registry_destinations"))) { + dockerArgs.push(core.getInput("additional_registry_destinations")) + } + + return dockerArgs +} diff --git a/test.js b/test.js new file mode 100644 index 0000000..bcf33b0 --- /dev/null +++ b/test.js @@ -0,0 +1,3 @@ + + +console.log("" != null)