Merge pull request #25 from crazy-max/throw-error

Throw error message instead of exit code
This commit is contained in:
CrazyMax
2021-05-14 02:26:52 +02:00
committed by GitHub
4 changed files with 42 additions and 14 deletions

View File

@@ -56,7 +56,27 @@ jobs:
if: always()
uses: crazy-max/ghaction-dump-context@v1
error:
error-msg:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Build
continue-on-error: true
uses: ./
with:
files: |
./test/config.hcl
set: |
*.platform=linux/amd64,linux/ppc64le,linux/s390x
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1
error-check:
runs-on: ubuntu-latest
steps:
-

16
dist/index.js generated vendored
View File

@@ -518,6 +518,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", { value: true });
const buildx = __importStar(__webpack_require__(295));
const context = __importStar(__webpack_require__(842));
const mexec = __importStar(__webpack_require__(757));
const core = __importStar(__webpack_require__(186));
const exec = __importStar(__webpack_require__(514));
function run() {
@@ -531,15 +532,18 @@ function run() {
core.setFailed(`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
return;
}
const buildxVersion = yield buildx.getVersion();
core.info(`Using buildx ${buildxVersion}`);
let inputs = yield context.getInputs();
const args = yield context.getArgs(inputs, buildxVersion);
const bxVersion = yield buildx.getVersion();
core.debug(`buildx version: ${bxVersion}`);
const inputs = yield context.getInputs();
const args = yield context.getArgs(inputs, bxVersion);
core.startGroup(`Bake definition`);
yield exec.exec('docker', [...args, '--print']);
core.endGroup();
core.info(`Building...`);
yield exec.exec('docker', args);
yield 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);

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