Throw error message instead of exit code

This commit is contained in:
CrazyMax
2021-05-14 02:10:53 +02:00
parent 1882cef5ad
commit a2173f5d12
4 changed files with 42 additions and 14 deletions

View File

@@ -7,7 +7,7 @@ export interface ExecResult {
stderr: string;
}
export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
export const exec = async (command: string, args: string[] = [], silent?: boolean): Promise<ExecResult> => {
let stdout: string = '';
let stderr: string = '';

View File

@@ -1,5 +1,6 @@
import * as buildx from './buildx';
import * as context from './context';
import * as mexec from './exec';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
@@ -15,18 +16,21 @@ async function run(): Promise<void> {
return;
}
const buildxVersion = await buildx.getVersion();
core.info(`Using buildx ${buildxVersion}`);
const bxVersion = await buildx.getVersion();
core.debug(`buildx version: ${bxVersion}`);
let inputs: context.Inputs = await context.getInputs();
const args: string[] = await context.getArgs(inputs, buildxVersion);
const inputs: context.Inputs = await context.getInputs();
const args: string[] = await context.getArgs(inputs, bxVersion);
core.startGroup(`Bake definition`);
await exec.exec('docker', [...args, '--print']);
core.endGroup();
core.info(`Building...`);
await exec.exec('docker', args);
await mexec.exec('docker', args).then(res => {
if (res.stderr.length > 0 && !res.success) {
throw new Error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)![0]}`);
}
});
} catch (error) {
core.setFailed(error.message);
}