From aacea38e0789aa44870965459363710fcab5f97d Mon Sep 17 00:00:00 2001 From: Jason D'Amour Date: Fri, 30 Jun 2023 20:02:02 -0500 Subject: [PATCH] feat: allow the `images` input to be empty, to output just tags Signed-off-by: Jason D'Amour --- src/main.ts | 4 ---- src/meta.ts | 21 +++++++++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index 2711e5d..b3d8fc8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,10 +15,6 @@ actionsToolkit.run( // main async () => { const inputs: Inputs = getInputs(); - if (inputs.images.length == 0) { - throw new Error(`images input required`); - } - const toolkit = new Toolkit({githubToken: inputs.githubToken}); const context = await getContext(inputs.context); const repo = await toolkit.github.repoData(); diff --git a/src/meta.ts b/src/meta.ts index a09f72d..febda9b 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -441,14 +441,27 @@ export class Meta { return []; } const tags: Array = []; - for (const imageName of this.getImageNames()) { - tags.push(`${imageName}:${this.version.main}`); + const images = this.getImageNames(); + if (Array.isArray(images) && images.length) { + for (const imageName of images) { + tags.push(`${imageName}:${this.version.main}`); + for (const partial of this.version.partial) { + tags.push(`${imageName}:${partial}`); + } + if (this.version.latest) { + const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`; + tags.push(`${imageName}:${Meta.sanitizeTag(latestTag)}`); + } + } + } + else { + tags.push(this.version.main); for (const partial of this.version.partial) { - tags.push(`${imageName}:${partial}`); + tags.push(partial); } if (this.version.latest) { const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`; - tags.push(`${imageName}:${Meta.sanitizeTag(latestTag)}`); + tags.push(Meta.sanitizeTag(latestTag)); } } return tags;