diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1185b06..50d1c27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: - diff --git a/dist/index.js b/dist/index.js index 9175b69..073e927 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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); diff --git a/src/exec.ts b/src/exec.ts index 3d0c4ce..00257e1 100644 --- a/src/exec.ts +++ b/src/exec.ts @@ -7,7 +7,7 @@ export interface ExecResult { stderr: string; } -export const exec = async (command: string, args: string[] = [], silent: boolean): Promise => { +export const exec = async (command: string, args: string[] = [], silent?: boolean): Promise => { let stdout: string = ''; let stderr: string = ''; diff --git a/src/main.ts b/src/main.ts index 509ce52..8b2bfbc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 { 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); }