From a017e545d776de19fe8aa2859f4734e0902e0740 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 18 Nov 2020 01:10:05 +0100 Subject: [PATCH] Remove duplicated tags --- __tests__/meta.test.ts | 28 ++++++++++++++++++++++++++++ dist/index.js | 1 + src/meta.ts | 1 + 3 files changed, 30 insertions(+) diff --git a/__tests__/meta.test.ts b/__tests__/meta.test.ts index 4c1dab2..b589a6c 100644 --- a/__tests__/meta.test.ts +++ b/__tests__/meta.test.ts @@ -683,6 +683,34 @@ describe('push tag', () => { "org.opencontainers.image.licenses=MIT" ] ], + [ + 'event_tag_v1.1.1.env', + { + images: ['org/app', 'ghcr.io/user/app'], + tagSemver: ['{{version}}', '{{major}}.{{minor}}.{{patch}}'], + } as Inputs, + { + main: '1.1.1', + partial: [], + latest: true + } as Version, + [ + 'org/app:1.1.1', + 'org/app:latest', + 'ghcr.io/user/app:1.1.1', + 'ghcr.io/user/app:latest' + ], + [ + "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", + "org.opencontainers.image.version=1.1.1", + "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", + "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071", + "org.opencontainers.image.licenses=MIT" + ] + ], [ 'event_tag_v2.0.8-beta.67.env', { diff --git a/dist/index.js b/dist/index.js index b2d3f3d..81db06c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -240,6 +240,7 @@ class Meta { else if (/^refs\/pull\//.test(this.context.ref)) { version.main = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`; } + version.partial = version.partial.filter((item, index) => version.partial.indexOf(item) === index); return version; } tags() { diff --git a/src/meta.ts b/src/meta.ts index 9921ed1..c0d5efa 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -82,6 +82,7 @@ export class Meta { version.main = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`; } + version.partial = version.partial.filter((item, index) => version.partial.indexOf(item) === index); return version; }