Skip to content

Commit aacea38

Browse files
jasondamourcrazy-max
authored andcommitted
feat: allow the images input to be empty, to output just tags
Signed-off-by: Jason D'Amour <[email protected]>
1 parent 051f7ea commit aacea38

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/main.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ actionsToolkit.run(
1515
// main
1616
async () => {
1717
const inputs: Inputs = getInputs();
18-
if (inputs.images.length == 0) {
19-
throw new Error(`images input required`);
20-
}
21-
2218
const toolkit = new Toolkit({githubToken: inputs.githubToken});
2319
const context = await getContext(inputs.context);
2420
const repo = await toolkit.github.repoData();

src/meta.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,27 @@ export class Meta {
441441
return [];
442442
}
443443
const tags: Array<string> = [];
444-
for (const imageName of this.getImageNames()) {
445-
tags.push(`${imageName}:${this.version.main}`);
444+
const images = this.getImageNames();
445+
if (Array.isArray(images) && images.length) {
446+
for (const imageName of images) {
447+
tags.push(`${imageName}:${this.version.main}`);
448+
for (const partial of this.version.partial) {
449+
tags.push(`${imageName}:${partial}`);
450+
}
451+
if (this.version.latest) {
452+
const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`;
453+
tags.push(`${imageName}:${Meta.sanitizeTag(latestTag)}`);
454+
}
455+
}
456+
}
457+
else {
458+
tags.push(this.version.main);
446459
for (const partial of this.version.partial) {
447-
tags.push(`${imageName}:${partial}`);
460+
tags.push(partial);
448461
}
449462
if (this.version.latest) {
450463
const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`;
451-
tags.push(`${imageName}:${Meta.sanitizeTag(latestTag)}`);
464+
tags.push(Meta.sanitizeTag(latestTag));
452465
}
453466
}
454467
return tags;

0 commit comments

Comments
 (0)