Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the images input to be empty, which outputs just the raw tags #307

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
required: true
images:
description: 'List of Docker images to use as base name for tags'
required: true
required: false
tags:
description: 'List of tags as key-value pair attributes'
required: false
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

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
20 changes: 16 additions & 4 deletions src/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,26 @@ 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