mirror of
https://code.forgejo.org/docker/metadata-action.git
synced 2025-08-27 16:30:54 +00:00
Allow to add custom tags (#24)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
9de4428611
commit
585ab8356c
6 changed files with 231 additions and 3 deletions
|
@ -10,6 +10,8 @@ export interface Inputs {
|
|||
tagMatchGroup: number;
|
||||
tagLatest: boolean;
|
||||
tagSchedule: string;
|
||||
tagCustom: string[];
|
||||
tagCustomOnly: boolean;
|
||||
sepTags: string;
|
||||
sepLabels: string;
|
||||
githubToken: string;
|
||||
|
@ -26,6 +28,8 @@ export function getInputs(): Inputs {
|
|||
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
||||
tagLatest: /true/i.test(core.getInput('tag-latest') || core.getInput('tag-match-latest') || 'true'),
|
||||
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
||||
tagCustom: getInputList('tag-custom'),
|
||||
tagCustomOnly: /true/i.test(core.getInput('tag-custom-only') || 'false'),
|
||||
sepTags: core.getInput('sep-tags') || `\n`,
|
||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||
githubToken: core.getInput('github-token')
|
||||
|
|
14
src/meta.ts
14
src/meta.ts
|
@ -33,7 +33,7 @@ export class Meta {
|
|||
|
||||
private getVersion(): Version {
|
||||
const currentDate = this.date;
|
||||
const version: Version = {
|
||||
let version: Version = {
|
||||
main: undefined,
|
||||
partial: [],
|
||||
latest: false
|
||||
|
@ -91,6 +91,18 @@ export class Meta {
|
|||
version.main = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
|
||||
}
|
||||
|
||||
if (this.inputs.tagCustom.length > 0) {
|
||||
if (this.inputs.tagCustomOnly) {
|
||||
version = {
|
||||
main: this.inputs.tagCustom.shift(),
|
||||
partial: this.inputs.tagCustom,
|
||||
latest: false
|
||||
};
|
||||
} else {
|
||||
version.partial.push(...this.inputs.tagCustom);
|
||||
}
|
||||
}
|
||||
|
||||
version.partial = version.partial.filter((item, index) => version.partial.indexOf(item) === index);
|
||||
return version;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue