Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-16 17:24:31 +02:00
parent 8be103ff82
commit 8913dd9900
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
3 changed files with 17 additions and 14 deletions

11
dist/index.js generated vendored
View file

@ -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;
});

View file

@ -46,25 +46,26 @@ export async function getInputs(): Promise<Inputs> {
};
}
export async function getArgs(inputs: Inputs): Promise<string[]> {
export async function getArgs(inputs: Inputs): Promise<Array<string>> {
let args: Array<string> = ['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<string[]> {
async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
let args: Array<string> = [];
if (inputs.noCache) {
args.push('--no-cache');
@ -81,7 +82,7 @@ async function getCommonArgs(inputs: Inputs): Promise<string[]> {
return args;
}
async function getBakeArgs(inputs: Inputs): Promise<string[]> {
async function getBakeArgs(inputs: Inputs): Promise<Array<string>> {
let args: Array<string> = ['bake'];
await asyncForEach(inputs.bakeFiles, async bakeFile => {
args.push('--file', bakeFile);
@ -89,7 +90,7 @@ async function getBakeArgs(inputs: Inputs): Promise<string[]> {
return args;
}
async function getBuildArgs(inputs: Inputs): Promise<string[]> {
async function getBuildArgs(inputs: Inputs): Promise<Array<string>> {
let args: Array<string> = ['build'];
await asyncForEach(inputs.buildArgs, async buildArg => {
args.push('--build-arg', buildArg);

View file

@ -17,6 +17,7 @@ async function run(): Promise<void> {
}
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<void> {
}
core.info(`🏃 Starting build...`);
await exec.exec('docker', await getArgs(inputs));
await exec.exec('docker', args);
} catch (error) {
core.setFailed(error.message);
}