Skip to content

Commit

Permalink
Add tag flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopeixoto committed Nov 18, 2020
1 parent 9ba75ef commit 5984e19
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
6 changes: 6 additions & 0 deletions action.yml
Expand Up @@ -49,6 +49,12 @@ inputs:
description: 'GitHub Token as provided by secrets'
default: ${{ github.token }}
required: true
flavor:
description: 'Container flavor, with no leading dash, like "alpine" or "debian"'
required: false
main-flavor:
description: 'Create tags without flavor as well'
required: false

outputs:
version:
Expand Down
27 changes: 22 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/context.ts
Expand Up @@ -13,6 +13,8 @@ export interface Inputs {
sepTags: string;
sepLabels: string;
githubToken: string;
flavor: string;
mainFlavor: boolean;
}

export function getInputs(): Inputs {
Expand All @@ -28,7 +30,9 @@ export function getInputs(): Inputs {
tagSchedule: core.getInput('tag-schedule') || 'nightly',
sepTags: core.getInput('sep-tags') || `\n`,
sepLabels: core.getInput('sep-labels') || `\n`,
githubToken: core.getInput('github-token')
githubToken: core.getInput('github-token'),
flavor: core.getInput('flavor') || '',
mainFlavor: /true/i.test(core.getInput('main-flavor') || 'true')
};
}

Expand Down
16 changes: 12 additions & 4 deletions src/meta.ts
Expand Up @@ -92,17 +92,25 @@ export class Meta {
return [];
}

let hasFlavor = this.inputs.flavor !== '';
let flavor = this.inputs.flavor;
let main = !hasFlavor || this.inputs.mainFlavor;

let tags: Array<string> = [];
for (const image of this.inputs.images) {
tags.push(`${image}:${version.main}`);
if (main) tags.push(`${image}:${version.main}`);
if (hasFlavor) tags.push(`${image}:${version.main}-${flavor}`);
for (const partial of version.partial) {
tags.push(`${image}:${partial}`);
if (main) tags.push(`${image}:${partial}`);
if (hasFlavor) tags.push(`${image}:${partial}-${flavor}`);
}
if (version.latest) {
tags.push(`${image}:latest`);
if (main) tags.push(`${image}:latest`);
if (hasFlavor) tags.push(`${image}:${flavor}`);
}
if (this.context.sha && this.inputs.tagSha) {
tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}`);
if (main) tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}`);
if (hasFlavor) tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}-${flavor}`);
}
}
return tags;
Expand Down

0 comments on commit 5984e19

Please sign in to comment.