From 52c4b1ad0ca86ca5528b7b59014e7d058c650bdc Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Sat, 31 Oct 2020 19:52:55 +0100 Subject: [PATCH] Handle tag-match-latest on Git tag event (#8) Co-authored-by: CrazyMax --- README.md | 2 +- __tests__/meta.test.ts | 25 +++++++++++++++++++++++++ action.yml | 2 +- dist/index.js | 2 +- src/meta.ts | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index de498ed..ebfc324 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Following inputs can be used as `step.with` keys | `tag-edge-branch` | String | Branch that will be tagged as edge (default `repo.default_branch`) | | `tag-match` | String | RegExp to match against a Git tag and use first match as Docker tag | | `tag-match-group` | Number | Group to get if `tag-match` matches (default `0`) | -| `tag-match-latest` | Bool | Set `latest` Docker tag if `tag-match` matches (default `true`) | +| `tag-match-latest` | Bool | Set `latest` Docker tag if `tag-match` matches or on Git tag event (default `true`) | | `tag-schedule` | String | [Template](#schedule-tag) to apply to schedule tag (default `nightly`) | | `sep-tags` | String | Separator to use for tags output (default `\n`) | | `sep-labels` | String | Separator to use for labels output (default `\n`) | diff --git a/__tests__/meta.test.ts b/__tests__/meta.test.ts index 27bb9db..7f2f0b2 100644 --- a/__tests__/meta.test.ts +++ b/__tests__/meta.test.ts @@ -734,6 +734,31 @@ describe('latest', () => { "org.opencontainers.image.licenses=MIT" ] ], + [ + 'event_tag_v1.1.1.env', + { + images: ['org/app', 'ghcr.io/user/app'], + tagMatchLatest: false, + } as Inputs, + { + version: 'v1.1.1', + latest: false + } as Version, + [ + 'org/app:v1.1.1', + 'ghcr.io/user/app:v1.1.1', + ], + [ + "org.opencontainers.image.title=Hello-World", + "org.opencontainers.image.description=This your first repo!", + "org.opencontainers.image.url=https://github.com/octocat/Hello-World", + "org.opencontainers.image.source=https://github.com/octocat/Hello-World.git", + "org.opencontainers.image.version=v1.1.1", + "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", + "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071", + "org.opencontainers.image.licenses=MIT" + ] + ], ])('given %p event ', tagsLabelsTest); }); diff --git a/action.yml b/action.yml index dfc3ae8..7403a2d 100644 --- a/action.yml +++ b/action.yml @@ -29,7 +29,7 @@ inputs: default: '0' required: false tag-match-latest: - description: 'Set latest Docker tag if tag-match matches' + description: 'Set latest Docker tag if tag-match matches or on Git tag event' default: 'true' required: false tag-schedule: diff --git a/dist/index.js b/dist/index.js index 1706fc8..78fefa3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -209,7 +209,7 @@ class Meta { } } else { - version.latest = true; + version.latest = this.inputs.tagMatchLatest; } } else if (/^refs\/heads\//.test(this.context.ref)) { diff --git a/src/meta.ts b/src/meta.ts index f580a61..5c36a87 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -53,7 +53,7 @@ export class Meta { version.latest = this.inputs.tagMatchLatest; } } else { - version.latest = true; + version.latest = this.inputs.tagMatchLatest; } } else if (/^refs\/heads\//.test(this.context.ref)) { version.version = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');