2020-10-25 02:25:23 +01:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
|
|
|
|
export interface Inputs {
|
|
|
|
images: string[];
|
|
|
|
tagSha: boolean;
|
|
|
|
tagEdge: string;
|
2020-10-25 15:13:43 +01:00
|
|
|
tagSchedule: string;
|
2020-10-25 02:25:23 +01:00
|
|
|
sepTags: string;
|
|
|
|
sepLabels: string;
|
|
|
|
githubToken: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getInputs(): Inputs {
|
|
|
|
return {
|
|
|
|
images: getInputList('images'),
|
|
|
|
tagSha: /true/i.test(core.getInput('tag-sha')),
|
|
|
|
tagEdge: core.getInput('tag-edge'),
|
2020-10-25 15:13:43 +01:00
|
|
|
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
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')
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|