2020-10-25 09:25:23 +08:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
|
|
|
|
export interface Inputs {
|
|
|
|
images: string[];
|
|
|
|
tagSha: boolean;
|
2020-10-25 22:32:14 +08:00
|
|
|
tagEdge: boolean;
|
|
|
|
tagEdgeBranch: string;
|
2020-11-18 06:31:03 +08:00
|
|
|
tagSemver: string[];
|
2020-10-27 07:57:32 +08:00
|
|
|
tagMatch: string;
|
2020-10-27 09:32:26 +08:00
|
|
|
tagMatchGroup: number;
|
2020-12-01 13:29:34 +08:00
|
|
|
tagLatest: boolean;
|
2020-10-25 22:13:43 +08:00
|
|
|
tagSchedule: string;
|
2020-12-05 01:12:39 +08:00
|
|
|
tagCustom: string[];
|
|
|
|
tagCustomOnly: boolean;
|
2020-10-25 09:25:23 +08:00
|
|
|
sepTags: string;
|
|
|
|
sepLabels: string;
|
|
|
|
githubToken: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getInputs(): Inputs {
|
|
|
|
return {
|
|
|
|
images: getInputList('images'),
|
2020-10-25 22:32:14 +08:00
|
|
|
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
|
|
|
|
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
|
|
|
|
tagEdgeBranch: core.getInput('tag-edge-branch'),
|
2020-11-18 06:31:03 +08:00
|
|
|
tagSemver: getInputList('tag-semver'),
|
2020-10-27 07:57:32 +08:00
|
|
|
tagMatch: core.getInput('tag-match'),
|
2020-10-27 09:32:26 +08:00
|
|
|
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
2020-12-01 13:29:34 +08:00
|
|
|
tagLatest: /true/i.test(core.getInput('tag-latest') || core.getInput('tag-match-latest') || 'true'),
|
2020-10-25 22:13:43 +08:00
|
|
|
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
2020-12-05 01:12:39 +08:00
|
|
|
tagCustom: getInputList('tag-custom'),
|
|
|
|
tagCustomOnly: /true/i.test(core.getInput('tag-custom-only') || 'false'),
|
2020-10-25 09:25:23 +08:00
|
|
|
sepTags: core.getInput('sep-tags') || `\n`,
|
|
|
|
sepLabels: core.getInput('sep-labels') || `\n`,
|
|
|
|
githubToken: core.getInput('github-token')
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getInputList(name: string): string[] {
|
|
|
|
const items = core.getInput(name);
|
|
|
|
if (items == '') {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return items
|
|
|
|
.split(/\r?\n/)
|
|
|
|
.filter(x => x)
|
|
|
|
.reduce<string[]>((acc, line) => acc.concat(line.split(',').filter(x => x)).map(pat => pat.trim()), []);
|
|
|
|
}
|
|
|
|
|
|
|
|
export const asyncForEach = async (array, callback) => {
|
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
await callback(array[index], index, array);
|
|
|
|
}
|
|
|
|
};
|