assembled docker args

This commit is contained in:
David Hiendl 2023-12-02 20:22:16 +01:00
parent ae28309b42
commit eeebfeb67a
4 changed files with 84 additions and 7 deletions

43
dist/index.js vendored
View File

@ -62235,6 +62235,38 @@ function prepareDestinations(registries, tags) {
return destinations; 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 ;// CONCATENATED MODULE: ./src/action.js
@ -62244,9 +62276,9 @@ function prepareDestinations(registries, tags) {
try { try {
const information = collect_all(true, false); const information = collect_all(true, false);
let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true; let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true;
console.log("debug=", debug) console.log('debug=', debug);
debug=true debug = true;
let targetRegistries = []; let targetRegistries = [];
const repoStr = github.context.repo.owner + '/' + github.context.repo.repo; const repoStr = github.context.repo.owner + '/' + github.context.repo.repo;
@ -62272,6 +62304,11 @@ try {
if (debug) { if (debug) {
console.log('destinations:', JSON.stringify(destinations, null, 2)); console.log('destinations:', JSON.stringify(destinations, null, 2));
} }
const dockerArgs = prepareDockerArgs(destinations);
if (debug) {
console.log('dockerArgs:', JSON.stringify(destinations, null, 2));
}
} }
catch (error) { catch (error) {
console.log('Failed to build docker image', error); console.log('Failed to build docker image', error);

View File

@ -5,7 +5,7 @@ import {
addCiRegistryAuth, addCiRegistryAuth,
collectTags, collectTags,
mergeArgRegistryAuthJson, mergeArgRegistryAuthJson,
prepareDestinations, prepareDestinations, prepareDockerArgs,
processAdditionalRegistries, processAdditionalRegistries,
writeRegistryAuthJson writeRegistryAuthJson
} from './lib'; } from './lib';
@ -13,9 +13,9 @@ import {
try { try {
const information = action_information.collect_all(true, false); const information = action_information.collect_all(true, false);
let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true; let debug = core.getInput('debug') != null ? (!!core.getInput('debug')) : true;
console.log("debug=", debug) console.log('debug=', debug);
debug=true debug = true;
let targetRegistries = []; let targetRegistries = [];
const repoStr = github.context.repo.owner + '/' + github.context.repo.repo; const repoStr = github.context.repo.owner + '/' + github.context.repo.repo;
@ -41,6 +41,11 @@ try {
if (debug) { if (debug) {
console.log('destinations:', JSON.stringify(destinations, null, 2)); console.log('destinations:', JSON.stringify(destinations, null, 2));
} }
const dockerArgs = prepareDockerArgs(destinations);
if (debug) {
console.log('dockerArgs:', JSON.stringify(destinations, null, 2));
}
} }
catch (error) { catch (error) {
console.log('Failed to build docker image', error); console.log('Failed to build docker image', error);

View File

@ -134,3 +134,35 @@ export function prepareDestinations(registries, tags) {
return destinations; 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
}

3
test.js Normal file
View File

@ -0,0 +1,3 @@
console.log("" != null)