feat: add tag-suffix and tag-prefix options

This commit is contained in:
CharlieC3 2021-03-08 16:52:14 -05:00
parent 5f29dbc7d7
commit 983af1f9f4
No known key found for this signature in database
GPG key ID: 0DDC8A2437C56218
6 changed files with 167 additions and 8 deletions

View file

@ -18,6 +18,8 @@ export interface Inputs {
tagSchedule: string;
tagCustom: string[];
tagCustomOnly: boolean;
tagSuffix: string;
tagPrefix: string;
labelCustom: string[];
sepTags: string;
sepLabels: string;
@ -44,6 +46,8 @@ export function getInputs(): Inputs {
tagSchedule: core.getInput('tag-schedule') || 'nightly',
tagCustom: getInputList('tag-custom'),
tagCustomOnly: /true/i.test(core.getInput('tag-custom-only') || 'false'),
tagSuffix: core.getInput('tag-suffix'),
tagPrefix: core.getInput('tag-prefix'),
labelCustom: getInputList('label-custom'),
sepTags: core.getInput('sep-tags') || `\n`,
sepLabels: core.getInput('sep-labels') || `\n`,

View file

@ -117,15 +117,15 @@ export class Meta {
let tags: Array<string> = [];
for (const image of this.inputs.images) {
const imageLc = image.toLowerCase();
tags.push(`${imageLc}:${this.version.main}`);
tags.push(`${imageLc}:${this.inputs.tagPrefix}${this.version.main}${this.inputs.tagSuffix}`);
for (const partial of this.version.partial) {
tags.push(`${imageLc}:${partial}`);
tags.push(`${imageLc}:${this.inputs.tagPrefix}${partial}${this.inputs.tagSuffix}`);
}
if (this.version.latest) {
tags.push(`${imageLc}:latest`);
tags.push(`${imageLc}:${this.inputs.tagPrefix}latest${this.inputs.tagSuffix}`);
}
if (this.context.sha && this.inputs.tagSha) {
tags.push(`${imageLc}:sha-${this.context.sha.substr(0, 7)}`);
tags.push(`${imageLc}:${this.inputs.tagPrefix}sha-${this.context.sha.substr(0, 7)}${this.inputs.tagSuffix}`);
}
}
return tags;