mirror of
https://code.forgejo.org/docker/metadata-action.git
synced 2025-09-16 01:36:57 +00:00
Initial commit
This commit is contained in:
commit
90ec551e12
42 changed files with 14168 additions and 0 deletions
38
src/context.ts
Normal file
38
src/context.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import * as core from '@actions/core';
|
||||
|
||||
export interface Inputs {
|
||||
images: string[];
|
||||
tagSha: boolean;
|
||||
tagEdge: string;
|
||||
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'),
|
||||
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);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue