Compare commits

..

7 Commits

Author SHA1 Message Date
CrazyMax 03bdd49965 Merge pull request #27 from crazy-max/bool-input
Use `core.getBooleanInput`
2021-05-26 15:25:24 +02:00
CrazyMax 41a29e21ad Use core.getBooleanInput 2021-05-26 15:22:22 +02:00
CrazyMax e0c37242bd Merge pull request #26 from docker/dependabot/npm_and_yarn/actions/core-1.3.0
Bump @actions/core from 1.2.7 to 1.3.0
2021-05-24 23:54:54 +02:00
CrazyMax 68d82b0527 Update generated content 2021-05-24 23:51:39 +02:00
dependabot[bot] 422e39df00 Bump @actions/core from 1.2.7 to 1.3.0
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.7 to 1.3.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-24 07:28:36 +00:00
CrazyMax 180a839280 Merge pull request #25 from crazy-max/throw-error
Throw error message instead of exit code
2021-05-14 02:26:52 +02:00
CrazyMax a2173f5d12 Throw error message instead of exit code 2021-05-14 02:10:58 +02:00
10 changed files with 135 additions and 41 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

+21 -1
View File
@@ -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:
- -
+2
View File
@@ -14,6 +14,8 @@ of this action in your workflow (i.e `docker/bake-action@v1.1.3`).
GitHub Action to use Docker [Buildx Bake](https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md) GitHub Action to use Docker [Buildx Bake](https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md)
as a high-level build command. as a high-level build command.
![Screenshot](.github/bake-action.png)
___ ___
* [Usage](#usage) * [Usage](#usage)
+1 -1
View File
@@ -188,7 +188,7 @@ describe('setOutput', () => {
}); });
}); });
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67 // See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
function getInputName(name: string): string { function getInputName(name: string): string {
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`; return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
} }
Generated Vendored
+92 -22
View File
@@ -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,17 @@ 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}`); const inputs = yield context.getInputs();
let inputs = yield context.getInputs(); const args = yield context.getArgs(inputs, bxVersion);
const args = yield context.getArgs(inputs, buildxVersion);
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);
@@ -1596,6 +1599,25 @@ module.exports = minVersion
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
@@ -1605,14 +1627,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
const command_1 = __webpack_require__(241); const command_1 = __webpack_require__(241);
const file_command_1 = __webpack_require__(717); const file_command_1 = __webpack_require__(717);
const utils_1 = __webpack_require__(278); const utils_1 = __webpack_require__(278);
@@ -1679,7 +1695,9 @@ function addPath(inputPath) {
} }
exports.addPath = addPath; exports.addPath = addPath;
/** /**
* Gets the value of an input. The value is also trimmed. * Gets the value of an input.
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
* Returns an empty string if the value is not defined.
* *
* @param name name of the input to get * @param name name of the input to get
* @param options optional. See InputOptions. * @param options optional. See InputOptions.
@@ -1690,9 +1708,34 @@ function getInput(name, options) {
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
} }
if (options && options.trimWhitespace === false) {
return val;
}
return val.trim(); return val.trim();
} }
exports.getInput = getInput; exports.getInput = getInput;
/**
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
* The return value is also in boolean type.
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns boolean
*/
function getBooleanInput(name, options) {
const trueValue = ['true', 'True', 'TRUE'];
const falseValue = ['false', 'False', 'FALSE'];
const val = getInput(name, options);
if (trueValue.includes(val))
return true;
if (falseValue.includes(val))
return false;
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports.getBooleanInput = getBooleanInput;
/** /**
* Sets the value of an output. * Sets the value of an output.
* *
@@ -1852,14 +1895,27 @@ module.exports = lt
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.issue = exports.issueCommand = void 0;
const os = __importStar(__webpack_require__(87)); const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(278); const utils_1 = __webpack_require__(278);
/** /**
@@ -1941,6 +1997,7 @@ function escapeProperty(s) {
// We use any as a valid input type // We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.toCommandValue = void 0;
/** /**
* Sanitizes an input into a string so it can be passed into issueCommand safely * Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string * @param input input to sanitize into a string
@@ -3701,14 +3758,27 @@ module.exports = toComparators
"use strict"; "use strict";
// For internal use, subject to change. // For internal use, subject to change.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.issueCommand = void 0;
// We use any as a valid input type // We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
@@ -5726,10 +5796,10 @@ function getInputs() {
builder: core.getInput('builder'), builder: core.getInput('builder'),
files: getInputList('files'), files: getInputList('files'),
targets: getInputList('targets'), targets: getInputList('targets'),
noCache: /true/i.test(core.getInput('no-cache')), noCache: core.getBooleanInput('no-cache'),
pull: /true/i.test(core.getInput('pull')), pull: core.getBooleanInput('pull'),
load: /true/i.test(core.getInput('load')), load: core.getBooleanInput('load'),
push: /true/i.test(core.getInput('push')), push: core.getBooleanInput('push'),
set: getInputList('set', true) set: getInputList('set', true)
}; };
}); });
+1 -1
View File
@@ -28,7 +28,7 @@
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.7", "@actions/core": "^1.3.0",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"csv-parse": "^4.15.4", "csv-parse": "^4.15.4",
"semver": "^7.3.5" "semver": "^7.3.5"
+4 -4
View File
@@ -19,10 +19,10 @@ export async function getInputs(): Promise<Inputs> {
builder: core.getInput('builder'), builder: core.getInput('builder'),
files: getInputList('files'), files: getInputList('files'),
targets: getInputList('targets'), targets: getInputList('targets'),
noCache: /true/i.test(core.getInput('no-cache')), noCache: core.getBooleanInput('no-cache'),
pull: /true/i.test(core.getInput('pull')), pull: core.getBooleanInput('pull'),
load: /true/i.test(core.getInput('load')), load: core.getBooleanInput('load'),
push: /true/i.test(core.getInput('push')), push: core.getBooleanInput('push'),
set: getInputList('set', true) set: getInputList('set', true)
}; };
} }
+1 -1
View File
@@ -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 = '';
+9 -7
View File
@@ -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,19 @@ async function run(): Promise<void> {
return; return;
} }
const buildxVersion = await buildx.getVersion(); const bxVersion = await buildx.getVersion();
core.info(`Using buildx ${buildxVersion}`); const inputs: context.Inputs = await context.getInputs();
const args: string[] = await context.getArgs(inputs, bxVersion);
let inputs: context.Inputs = await context.getInputs();
const args: string[] = await context.getArgs(inputs, buildxVersion);
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);
} }
+4 -4
View File
@@ -2,10 +2,10 @@
# yarn lockfile v1 # yarn lockfile v1
"@actions/core@^1.2.7": "@actions/core@^1.3.0":
version "1.2.7" version "1.3.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.7.tgz#594f8c45b213f0146e4be7eda8ae5cf4e198e5ab" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.3.0.tgz#f5e4b24c889e7f2e58b466cc8c7481292284eba0"
integrity sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig== integrity sha512-xxtX0Cwdhb8LcgatfJkokqT8KzPvcIbwL9xpLU09nOwBzaStbfm0dNncsP0M4us+EpoPdWy7vbzU5vSOH7K6pg==
"@actions/exec@^1.0.4": "@actions/exec@^1.0.4":
version "1.0.4" version "1.0.4"