mirror of
https://github.com/docker/bake-action.git
synced 2026-01-22 20:32:21 +01:00
Throw error message instead of exit code
This commit is contained in:
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@@ -56,7 +56,27 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
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
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
|
|||||||
16
dist/index.js
generated
vendored
16
dist/index.js
generated
vendored
@@ -518,6 +518,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const buildx = __importStar(__webpack_require__(295));
|
const buildx = __importStar(__webpack_require__(295));
|
||||||
const context = __importStar(__webpack_require__(842));
|
const context = __importStar(__webpack_require__(842));
|
||||||
|
const mexec = __importStar(__webpack_require__(757));
|
||||||
const core = __importStar(__webpack_require__(186));
|
const core = __importStar(__webpack_require__(186));
|
||||||
const exec = __importStar(__webpack_require__(514));
|
const exec = __importStar(__webpack_require__(514));
|
||||||
function run() {
|
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.`);
|
core.setFailed(`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const buildxVersion = yield buildx.getVersion();
|
const bxVersion = yield buildx.getVersion();
|
||||||
core.info(`Using buildx ${buildxVersion}`);
|
core.debug(`buildx version: ${bxVersion}`);
|
||||||
let inputs = yield context.getInputs();
|
const inputs = yield context.getInputs();
|
||||||
const args = yield context.getArgs(inputs, buildxVersion);
|
const args = yield context.getArgs(inputs, bxVersion);
|
||||||
core.startGroup(`Bake definition`);
|
core.startGroup(`Bake definition`);
|
||||||
yield exec.exec('docker', [...args, '--print']);
|
yield exec.exec('docker', [...args, '--print']);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.info(`Building...`);
|
yield mexec.exec('docker', args).then(res => {
|
||||||
yield exec.exec('docker', args);
|
if (res.stderr.length > 0 && !res.success) {
|
||||||
|
throw new Error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)[0]}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export interface ExecResult {
|
|||||||
stderr: string;
|
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 stdout: string = '';
|
||||||
let stderr: string = '';
|
let stderr: string = '';
|
||||||
|
|
||||||
|
|||||||
16
src/main.ts
16
src/main.ts
@@ -1,5 +1,6 @@
|
|||||||
import * as buildx from './buildx';
|
import * as buildx from './buildx';
|
||||||
import * as context from './context';
|
import * as context from './context';
|
||||||
|
import * as mexec from './exec';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
@@ -15,18 +16,21 @@ async function run(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildxVersion = await buildx.getVersion();
|
const bxVersion = await buildx.getVersion();
|
||||||
core.info(`Using buildx ${buildxVersion}`);
|
core.debug(`buildx version: ${bxVersion}`);
|
||||||
|
|
||||||
let inputs: context.Inputs = await context.getInputs();
|
const inputs: context.Inputs = await context.getInputs();
|
||||||
const args: string[] = await context.getArgs(inputs, buildxVersion);
|
const args: string[] = await context.getArgs(inputs, bxVersion);
|
||||||
|
|
||||||
core.startGroup(`Bake definition`);
|
core.startGroup(`Bake definition`);
|
||||||
await exec.exec('docker', [...args, '--print']);
|
await exec.exec('docker', [...args, '--print']);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
core.info(`Building...`);
|
await mexec.exec('docker', args).then(res => {
|
||||||
await exec.exec('docker', args);
|
if (res.stderr.length > 0 && !res.success) {
|
||||||
|
throw new Error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)![0]}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user