From 8913dd99000a24c4af7add65087eb69190206c57 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 16 Aug 2020 17:24:31 +0200 Subject: [PATCH] Fix args Signed-off-by: CrazyMax --- dist/index.js | 11 ++++++----- src/context.ts | 17 +++++++++-------- src/main.ts | 3 ++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index ac8f509..26fede8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1018,12 +1018,13 @@ function run() { return; } const inputs = yield context_1.getInputs(); + const args = yield context_1.getArgs(inputs); if (inputs.builder) { core.info(`📌 Using builder instance ${inputs.builder}`); yield buildx.use(inputs.builder); } core.info(`🏃 Starting build...`); - yield exec.exec('docker', yield context_1.getArgs(inputs)); + yield exec.exec('docker', args); } catch (error) { core.setFailed(error.message); @@ -1436,17 +1437,17 @@ function getArgs(inputs) { return __awaiter(this, void 0, void 0, function* () { let args = ['buildx']; if (inputs.bake) { - args.concat(yield getBakeArgs(inputs)); + args.push.apply(args, yield getBakeArgs(inputs)); } else { - args.concat(yield getBuildArgs(inputs)); + args.push.apply(args, yield getBuildArgs(inputs)); } - args.concat(yield getCommonArgs(inputs)); + args.push.apply(args, yield getCommonArgs(inputs)); if (!inputs.bake) { args.push(inputs.context); } else { - args.concat(inputs.bakeTargets); + args.push.apply(args, inputs.bakeTargets); } return args; }); diff --git a/src/context.ts b/src/context.ts index 54a5c9a..19530d8 100644 --- a/src/context.ts +++ b/src/context.ts @@ -46,25 +46,26 @@ export async function getInputs(): Promise { }; } -export async function getArgs(inputs: Inputs): Promise { +export async function getArgs(inputs: Inputs): Promise> { let args: Array = ['buildx']; + if (inputs.bake) { - args.concat(await getBakeArgs(inputs)); + args.push.apply(args, await getBakeArgs(inputs)); } else { - args.concat(await getBuildArgs(inputs)); + args.push.apply(args, await getBuildArgs(inputs)); } - args.concat(await getCommonArgs(inputs)); + args.push.apply(args, await getCommonArgs(inputs)); if (!inputs.bake) { args.push(inputs.context); } else { - args.concat(inputs.bakeTargets); + args.push.apply(args, inputs.bakeTargets); } return args; } -async function getCommonArgs(inputs: Inputs): Promise { +async function getCommonArgs(inputs: Inputs): Promise> { let args: Array = []; if (inputs.noCache) { args.push('--no-cache'); @@ -81,7 +82,7 @@ async function getCommonArgs(inputs: Inputs): Promise { return args; } -async function getBakeArgs(inputs: Inputs): Promise { +async function getBakeArgs(inputs: Inputs): Promise> { let args: Array = ['bake']; await asyncForEach(inputs.bakeFiles, async bakeFile => { args.push('--file', bakeFile); @@ -89,7 +90,7 @@ async function getBakeArgs(inputs: Inputs): Promise { return args; } -async function getBuildArgs(inputs: Inputs): Promise { +async function getBuildArgs(inputs: Inputs): Promise> { let args: Array = ['build']; await asyncForEach(inputs.buildArgs, async buildArg => { args.push('--build-arg', buildArg); diff --git a/src/main.ts b/src/main.ts index 2fc36ef..7e13313 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,6 +17,7 @@ async function run(): Promise { } const inputs: Inputs = await getInputs(); + const args: string[] = await getArgs(inputs); if (inputs.builder) { core.info(`📌 Using builder instance ${inputs.builder}`); @@ -24,7 +25,7 @@ async function run(): Promise { } core.info(`🏃 Starting build...`); - await exec.exec('docker', await getArgs(inputs)); + await exec.exec('docker', args); } catch (error) { core.setFailed(error.message); }