Skip to content

Commit

Permalink
feat: allow the images input to be empty, to output just tags
Browse files Browse the repository at this point in the history
Signed-off-by: Jason D'Amour <[email protected]>
  • Loading branch information
jasondamour authored and crazy-max committed Nov 30, 2023
1 parent 051f7ea commit aacea38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 17 additions & 4 deletions src/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,27 @@ export class Meta {
return [];
}
const tags: Array<string> = [];
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;
Expand Down

0 comments on commit aacea38

Please sign in to comment.