Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e09df4df3c | ||
|
72e5d60481 | ||
|
ae431178c1 | ||
|
34ebfd6e6b | ||
|
94641ff1bb | ||
|
40bfc8b527 |
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.4.0 (2021/04/30)
|
||||||
|
|
||||||
|
* Add `bake-target` input (#69)
|
||||||
|
* Fix setOutput (#67)
|
||||||
|
* Bump csv-parse from 4.15.3 to 4.15.4 (#65)
|
||||||
|
* Bump @actions/core from 1.2.6 to 1.2.7 (#64)
|
||||||
|
|
||||||
## 2.3.0 (2021/04/07)
|
## 2.3.0 (2021/04/07)
|
||||||
|
|
||||||
* Allow overriding flavor (#63)
|
* Allow overriding flavor (#63)
|
||||||
|
@@ -271,6 +271,7 @@ Following inputs can be used as `step.with` keys
|
|||||||
| `labels` | List | List of custom labels |
|
| `labels` | List | List of custom labels |
|
||||||
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
|
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
|
||||||
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
||||||
|
| `bake-target` | String | Bake target name (default `ghaction-docker-meta`) |
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
|
@@ -147,8 +147,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context';
|
||||||
@@ -171,6 +172,27 @@ describe('asyncForEach', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setOutput', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
process.stdout.write = jest.fn();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setOutput produces the correct command', () => {
|
||||||
|
context.setOutput('some output', 'some value');
|
||||||
|
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setOutput handles bools', () => {
|
||||||
|
context.setOutput('some output', false);
|
||||||
|
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setOutput handles numbers', () => {
|
||||||
|
context.setOutput('some output', 1.01);
|
||||||
|
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||||
function getInputName(name: string): string {
|
function getInputName(name: string): string {
|
||||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
@@ -179,3 +201,11 @@ function getInputName(name: string): string {
|
|||||||
function setInput(name: string, value: string): void {
|
function setInput(name: string, value: string): void {
|
||||||
process.env[getInputName(name)] = value;
|
process.env[getInputName(name)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assert that process.stdout.write calls called only with the given arguments.
|
||||||
|
function assertWriteCalls(calls: string[]): void {
|
||||||
|
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
||||||
|
for (let i = 0; i < calls.length; i++) {
|
||||||
|
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -2392,11 +2392,12 @@ describe('bake', () => {
|
|||||||
`type=raw,my`,
|
`type=raw,my`,
|
||||||
`type=raw,custom`,
|
`type=raw,custom`,
|
||||||
`type=raw,tags`
|
`type=raw,tags`
|
||||||
]
|
],
|
||||||
|
bakeTarget: "meta"
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
"target": {
|
"target": {
|
||||||
"ghaction-docker-meta": {
|
"meta": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"user/app:release1",
|
"user/app:release1",
|
||||||
"user/app:my",
|
"user/app:my",
|
||||||
|
@@ -25,6 +25,9 @@ inputs:
|
|||||||
sep-labels:
|
sep-labels:
|
||||||
description: 'Separator to use for labels output (default \n)'
|
description: 'Separator to use for labels output (default \n)'
|
||||||
required: false
|
required: false
|
||||||
|
bake-target:
|
||||||
|
description: 'Bake target name (default ghaction-docker-meta)'
|
||||||
|
required: false
|
||||||
github-token:
|
github-token:
|
||||||
description: 'GitHub Token as provided by secrets'
|
description: 'GitHub Token as provided by secrets'
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
22
dist/index.js
generated
vendored
22
dist/index.js
generated
vendored
@@ -39,9 +39,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.asyncForEach = exports.getInputList = exports.getInputs = exports.tmpDir = void 0;
|
exports.setOutput = exports.asyncForEach = exports.getInputList = exports.getInputs = exports.tmpDir = void 0;
|
||||||
const sync_1 = __importDefault(__webpack_require__(8750));
|
const sync_1 = __importDefault(__webpack_require__(8750));
|
||||||
const core = __importStar(__webpack_require__(2186));
|
const core = __importStar(__webpack_require__(2186));
|
||||||
|
const command_1 = __webpack_require__(7351);
|
||||||
const fs = __importStar(__webpack_require__(5747));
|
const fs = __importStar(__webpack_require__(5747));
|
||||||
const os = __importStar(__webpack_require__(2087));
|
const os = __importStar(__webpack_require__(2087));
|
||||||
const path = __importStar(__webpack_require__(5622));
|
const path = __importStar(__webpack_require__(5622));
|
||||||
@@ -61,6 +62,7 @@ function getInputs() {
|
|||||||
labels: getInputList('labels', true),
|
labels: getInputList('labels', true),
|
||||||
sepTags: core.getInput('sep-tags') || `\n`,
|
sepTags: core.getInput('sep-tags') || `\n`,
|
||||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||||
|
bakeTarget: core.getInput('bake-target') || `ghaction-docker-meta`,
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -94,6 +96,11 @@ exports.asyncForEach = (array, callback) => __awaiter(void 0, void 0, void 0, fu
|
|||||||
yield callback(array[index], index, array);
|
yield callback(array[index], index, array);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||||
|
function setOutput(name, value) {
|
||||||
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
|
}
|
||||||
|
exports.setOutput = setOutput;
|
||||||
//# sourceMappingURL=context.js.map
|
//# sourceMappingURL=context.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -292,7 +299,7 @@ function run() {
|
|||||||
core.info(version.main || '');
|
core.info(version.main || '');
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
core.setOutput('version', version.main || '');
|
context_1.setOutput('version', version.main || '');
|
||||||
// Docker tags
|
// Docker tags
|
||||||
const tags = meta.getTags();
|
const tags = meta.getTags();
|
||||||
if (tags.length == 0) {
|
if (tags.length == 0) {
|
||||||
@@ -305,7 +312,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
core.setOutput('tags', tags.join(inputs.sepTags));
|
context_1.setOutput('tags', tags.join(inputs.sepTags));
|
||||||
// Docker labels
|
// Docker labels
|
||||||
const labels = meta.getLabels();
|
const labels = meta.getLabels();
|
||||||
core.startGroup(`Docker labels`);
|
core.startGroup(`Docker labels`);
|
||||||
@@ -313,13 +320,13 @@ function run() {
|
|||||||
core.info(label);
|
core.info(label);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('labels', labels.join(inputs.sepLabels));
|
context_1.setOutput('labels', labels.join(inputs.sepLabels));
|
||||||
// Bake definition file
|
// Bake definition file
|
||||||
const bakeFile = meta.getBakeFile();
|
const bakeFile = meta.getBakeFile();
|
||||||
core.startGroup(`Bake definition file`);
|
core.startGroup(`Bake definition file`);
|
||||||
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('bake-file', bakeFile);
|
context_1.setOutput('bake-file', bakeFile);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@@ -692,7 +699,7 @@ class Meta {
|
|||||||
const bakeFile = path.join(context_1.tmpDir(), 'ghaction-docker-meta-bake.json').split(path.sep).join(path.posix.sep);
|
const bakeFile = path.join(context_1.tmpDir(), 'ghaction-docker-meta-bake.json').split(path.sep).join(path.posix.sep);
|
||||||
fs.writeFileSync(bakeFile, JSON.stringify({
|
fs.writeFileSync(bakeFile, JSON.stringify({
|
||||||
target: {
|
target: {
|
||||||
'ghaction-docker-meta': {
|
[this.inputs.bakeTarget]: {
|
||||||
tags: this.getTags(),
|
tags: this.getTags(),
|
||||||
labels: jsonLabels,
|
labels: jsonLabels,
|
||||||
args: {
|
args: {
|
||||||
@@ -1118,6 +1125,7 @@ exports.getInput = getInput;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function setOutput(name, value) {
|
function setOutput(name, value) {
|
||||||
|
process.stdout.write(os.EOL);
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
@@ -5519,7 +5527,7 @@ class Parser extends Transform {
|
|||||||
for(let i = 0, l = record.length; i < l; i++){
|
for(let i = 0, l = record.length; i < l; i++){
|
||||||
if(columns[i] === undefined || columns[i].disabled) continue
|
if(columns[i] === undefined || columns[i].disabled) continue
|
||||||
// Turn duplicate columns into an array
|
// Turn duplicate columns into an array
|
||||||
if (columns_duplicates_to_array === true && obj[columns[i].name]) {
|
if (columns_duplicates_to_array === true && obj[columns[i].name] !== undefined) {
|
||||||
if (Array.isArray(obj[columns[i].name])) {
|
if (Array.isArray(obj[columns[i].name])) {
|
||||||
obj[columns[i].name] = obj[columns[i].name].concat(record[i])
|
obj[columns[i].name] = obj[columns[i].name].concat(record[i])
|
||||||
} else {
|
} else {
|
||||||
|
@@ -23,9 +23,9 @@
|
|||||||
"author": "CrazyMax",
|
"author": "CrazyMax",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.7",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^4.0.0",
|
||||||
"csv-parse": "^4.15.3",
|
"csv-parse": "^4.15.4",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"semver": "^7.3.5"
|
"semver": "^7.3.5"
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import csvparse from 'csv-parse/lib/sync';
|
import csvparse from 'csv-parse/lib/sync';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import {issueCommand} from '@actions/core/lib/command';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@@ -13,6 +14,7 @@ export interface Inputs {
|
|||||||
labels: string[];
|
labels: string[];
|
||||||
sepTags: string;
|
sepTags: string;
|
||||||
sepLabels: string;
|
sepLabels: string;
|
||||||
|
bakeTarget: string;
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +33,7 @@ export function getInputs(): Inputs {
|
|||||||
labels: getInputList('labels', true),
|
labels: getInputList('labels', true),
|
||||||
sepTags: core.getInput('sep-tags') || `\n`,
|
sepTags: core.getInput('sep-tags') || `\n`,
|
||||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||||
|
bakeTarget: core.getInput('bake-target') || `ghaction-docker-meta`,
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -66,3 +69,8 @@ export const asyncForEach = async (array, callback) => {
|
|||||||
await callback(array[index], index, array);
|
await callback(array[index], index, array);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||||
|
export function setOutput(name: string, value: any): void {
|
||||||
|
issueCommand('set-output', {name}, value);
|
||||||
|
}
|
||||||
|
10
src/main.ts
10
src/main.ts
@@ -1,5 +1,5 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import {getInputs, Inputs} from './context';
|
import {getInputs, Inputs, setOutput} from './context';
|
||||||
import * as github from './github';
|
import * as github from './github';
|
||||||
import {Meta, Version} from './meta';
|
import {Meta, Version} from './meta';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
@@ -36,7 +36,7 @@ async function run() {
|
|||||||
core.info(version.main || '');
|
core.info(version.main || '');
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
core.setOutput('version', version.main || '');
|
setOutput('version', version.main || '');
|
||||||
|
|
||||||
// Docker tags
|
// Docker tags
|
||||||
const tags: Array<string> = meta.getTags();
|
const tags: Array<string> = meta.getTags();
|
||||||
@@ -49,7 +49,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
core.setOutput('tags', tags.join(inputs.sepTags));
|
setOutput('tags', tags.join(inputs.sepTags));
|
||||||
|
|
||||||
// Docker labels
|
// Docker labels
|
||||||
const labels: Array<string> = meta.getLabels();
|
const labels: Array<string> = meta.getLabels();
|
||||||
@@ -58,14 +58,14 @@ async function run() {
|
|||||||
core.info(label);
|
core.info(label);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('labels', labels.join(inputs.sepLabels));
|
setOutput('labels', labels.join(inputs.sepLabels));
|
||||||
|
|
||||||
// Bake definition file
|
// Bake definition file
|
||||||
const bakeFile: string = meta.getBakeFile();
|
const bakeFile: string = meta.getBakeFile();
|
||||||
core.startGroup(`Bake definition file`);
|
core.startGroup(`Bake definition file`);
|
||||||
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('bake-file', bakeFile);
|
setOutput('bake-file', bakeFile);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
@@ -378,7 +378,7 @@ export class Meta {
|
|||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
{
|
{
|
||||||
target: {
|
target: {
|
||||||
'ghaction-docker-meta': {
|
[this.inputs.bakeTarget]: {
|
||||||
tags: this.getTags(),
|
tags: this.getTags(),
|
||||||
labels: jsonLabels,
|
labels: jsonLabels,
|
||||||
args: {
|
args: {
|
||||||
|
16
yarn.lock
16
yarn.lock
@@ -2,10 +2,10 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
"@actions/core@^1.2.6":
|
"@actions/core@^1.2.7":
|
||||||
version "1.2.6"
|
version "1.2.7"
|
||||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
|
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.7.tgz#594f8c45b213f0146e4be7eda8ae5cf4e198e5ab"
|
||||||
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
|
integrity sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig==
|
||||||
|
|
||||||
"@actions/github@^4.0.0":
|
"@actions/github@^4.0.0":
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
@@ -1176,10 +1176,10 @@ cssstyle@^2.2.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
cssom "~0.3.6"
|
cssom "~0.3.6"
|
||||||
|
|
||||||
csv-parse@^4.15.3:
|
csv-parse@^4.15.4:
|
||||||
version "4.15.3"
|
version "4.15.4"
|
||||||
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.15.3.tgz#8a62759617a920c328cb31c351b05053b8f92b10"
|
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.15.4.tgz#ad1ec62aaf71a642982dfcb81f1848184d691db5"
|
||||||
integrity sha512-jlTqDvLdHnYMSr08ynNfk4IAUSJgJjTKy2U5CQBSu4cN9vQOJonLVZP4Qo4gKKrIgIQ5dr07UwOJdi+lRqT12w==
|
integrity sha512-OdBbFc0yZhOm17lSxqkirrHlFFVpKRT0wp4DAGoJelsP3LbGzV9LNr7XmM/lrr0uGkCtaqac9UhP8PDHXOAbMg==
|
||||||
|
|
||||||
dashdash@^1.12.0:
|
dashdash@^1.12.0:
|
||||||
version "1.14.1"
|
version "1.14.1"
|
||||||
|
Reference in New Issue
Block a user