mirror of
https://github.com/docker/build-push-action.git
synced 2025-04-19 09:56:46 +00:00
Throw error message instead of exit code
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
5af5c5fa9d
commit
de804a56b7
5 changed files with 76 additions and 14 deletions
|
@ -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 = '';
|
||||
|
||||
|
|
14
src/main.ts
14
src/main.ts
|
@ -2,20 +2,18 @@ import * as fs from 'fs';
|
|||
import * as os from 'os';
|
||||
import * as buildx from './buildx';
|
||||
import * as context from './context';
|
||||
import * as exec from './exec';
|
||||
import * as stateHelper from './state-helper';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
if (os.platform() !== 'linux') {
|
||||
core.setFailed('Only supported on linux platform');
|
||||
return;
|
||||
throw new Error(`Only supported on linux platform`);
|
||||
}
|
||||
|
||||
if (!(await buildx.isAvailable())) {
|
||||
core.setFailed(`Buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
|
||||
return;
|
||||
throw new Error(`Buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
|
||||
}
|
||||
stateHelper.setTmpDir(context.tmpDir());
|
||||
|
||||
|
@ -27,7 +25,11 @@ async function run(): Promise<void> {
|
|||
|
||||
core.info(`🏃 Starting build...`);
|
||||
const args: string[] = await context.getArgs(inputs, defContext, buildxVersion);
|
||||
await exec.exec('docker', args);
|
||||
await exec.exec('docker', args).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(`buildx call failed with: ${res.stderr.match(/(.*)\s*$/)![0]}`);
|
||||
}
|
||||
});
|
||||
|
||||
const imageID = await buildx.getImageID();
|
||||
if (imageID) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue