2020-12-23 22:09:38 +01:00
|
|
|
import csvparse from 'csv-parse/lib/sync';
|
2020-10-25 02:25:23 +01:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
|
|
|
|
export interface Inputs {
|
|
|
|
images: string[];
|
|
|
|
tagSha: boolean;
|
2020-10-25 15:32:14 +01:00
|
|
|
tagEdge: boolean;
|
|
|
|
tagEdgeBranch: string;
|
2020-11-17 23:31:03 +01:00
|
|
|
tagSemver: string[];
|
2020-10-27 00:57:32 +01:00
|
|
|
tagMatch: string;
|
2020-10-27 02:32:26 +01:00
|
|
|
tagMatchGroup: number;
|
2020-12-01 06:29:34 +01:00
|
|
|
tagLatest: boolean;
|
2020-10-25 15:13:43 +01:00
|
|
|
tagSchedule: string;
|
2020-12-04 18:12:39 +01:00
|
|
|
tagCustom: string[];
|
|
|
|
tagCustomOnly: boolean;
|
2020-12-23 22:09:38 +01:00
|
|
|
labelCustom: string[];
|
2020-10-25 02:25:23 +01:00
|
|
|
sepTags: string;
|
|
|
|
sepLabels: string;
|
|
|
|
githubToken: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getInputs(): Inputs {
|
|
|
|
return {
|
|
|
|
images: getInputList('images'),
|
2020-10-25 15:32:14 +01: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-17 23:31:03 +01:00
|
|
|
tagSemver: getInputList('tag-semver'),
|
2020-10-27 00:57:32 +01:00
|
|
|
tagMatch: core.getInput('tag-match'),
|
2020-10-27 02:32:26 +01:00
|
|
|
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
2020-12-01 06:29:34 +01:00
|
|
|
tagLatest: /true/i.test(core.getInput('tag-latest') || core.getInput('tag-match-latest') || 'true'),
|
2020-10-25 15:13:43 +01:00
|
|
|
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
2020-12-04 18:12:39 +01:00
|
|
|
tagCustom: getInputList('tag-custom'),
|
|
|
|
tagCustomOnly: /true/i.test(core.getInput('tag-custom-only') || 'false'),
|
2020-12-23 22:09:38 +01:00
|
|
|
labelCustom: getInputList('label-custom'),
|
2020-10-25 02:25:23 +01:00
|
|
|
sepTags: core.getInput('sep-tags') || `\n`,
|
|
|
|
sepLabels: core.getInput('sep-labels') || `\n`,
|
|
|
|
githubToken: core.getInput('github-token')
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-23 22:09:38 +01:00
|
|
|
export function getInputList(name: string, ignoreComma?: boolean): string[] {
|
|
|
|
let res: Array<string> = [];
|
|
|
|
|
2020-10-25 02:25:23 +01:00
|
|
|
const items = core.getInput(name);
|
|
|
|
if (items == '') {
|
2020-12-23 22:09:38 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let output of csvparse(items, {
|
|
|
|
columns: false,
|
|
|
|
relaxColumnCount: true,
|
|
|
|
skipLinesWithEmptyValues: true
|
|
|
|
}) as Array<string[]>) {
|
|
|
|
if (output.length == 1) {
|
|
|
|
res.push(output[0]);
|
|
|
|
continue;
|
|
|
|
} else if (!ignoreComma) {
|
|
|
|
res.push(...output);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
res.push(output.join(','));
|
2020-10-25 02:25:23 +01:00
|
|
|
}
|
2020-12-23 22:09:38 +01:00
|
|
|
|
|
|
|
return res.filter(item => item).map(pat => pat.trim());
|
2020-10-25 02:25:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const asyncForEach = async (array, callback) => {
|
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
await callback(array[index], index, array);
|
|
|
|
}
|
|
|
|
};
|