Repository: crazy-max/ghaction-docker-meta (ts)

Issue:
Enable attribute is ignored for tags
### Behaviour

Global attribute `enable` for `tags` input (see [docs](https://github.com/crazy-max/ghaction-docker-meta#tags-input)) is ignored - even though it's set to `"false"`, annotated tag is still created.

#### Steps to reproduce this issue

1. Include `enable=false` in `tags` input, e.g.:
```
tags: |
  type=raw,value=foo
  type=raw,value=bar,enable=false
```
2. Try to build/tag image.

#### Expected behaviour

List of docker tags should not include `bar`.

#### Actual behaviour

List of docker tags contains both `foo` and `bar`:

### Logs

```
Run crazy-max/ghaction-docker-meta@v2
  with:
    images: testimage
    tags: type=raw,value=foo,
  type=raw,value=bar,enable=false
    github-token: ***

Context info
  eventName: pull_request
  sha: 99b0a688a109ec11aaafe1c3bf4c07296274ff32
  ref: refs/pull/1/merge
  workflow: CI
  action: crazy-maxghaction-docker-meta
  actor: jakub-bacic
  runNumber: 25
  runId: 700974690

Docker image version
  foo

Docker tags
  testimage:foo
  testimage:bar
...
```

Pull request:
Fix 'enable' tag attribute
Fixes #52

Patch:
diff --git a/dist/index.js b/dist/index.js
index 9050fa4..b21ab7b 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -361,6 +361,9 @@ class Meta {
             latest: undefined
         };
         for (const tag of this.tags) {
+            if (tag.attrs['enable'] == 'false') {
+                continue;
+            }
             switch (tag.type) {
                 case tcl.Type.Schedule: {
                     version = this.procSchedule(version, tag);
diff --git a/src/meta.ts b/src/meta.ts
index 25de61a..bd34e51 100644
--- a/src/meta.ts
+++ b/src/meta.ts
@@ -44,6 +44,10 @@ export class Meta {
     };
 
     for (const tag of this.tags) {
+      if (tag.attrs['enable'] == 'false') {
+        continue;
+      }
+
       switch (tag.type) {
         case tcl.Type.Schedule: {
           version = this.procSchedule(version, tag);


Test patch:
diff --git a/__tests__/meta.test.ts b/__tests__/meta.test.ts
index 071581e..03ee290 100644
--- a/__tests__/meta.test.ts
+++ b/__tests__/meta.test.ts
@@ -2015,7 +2015,41 @@ describe('raw', () => {
         "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
         "org.opencontainers.image.licenses=MIT"
       ]
-    ]
+    ],
+    [
+      'raw10',
+      'event_push.env',
+      {
+        images: ['user/app'],
+        tags: [
+          `type=raw,foo`,
+          `type=raw,bar,enable=false`,
+          `type=raw,baz,enable=true`
+        ],
+        flavor: [
+          `latest=false`
+        ]
+      } as Inputs,
+      {
+        main: 'foo',
+        partial: ['baz'],
+        latest: false
+      } as Version,
+      [
+        'user/app:foo',
+        'user/app:baz',
+      ],
+      [
+        "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=foo",
+        "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
+        "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
+        "org.opencontainers.image.licenses=MIT"
+      ]
+    ],
   ])('given %p wth %p event', tagsLabelsTest);
 });
 
@@ -2324,3 +2358,40 @@ describe('bake', () => {
     expect(JSON.parse(fs.readFileSync(bakeFile, 'utf8'))).toEqual(exBakeDefinition);
   });
 });
+
+describe('push', () => {
+  // prettier-ignore
+  test.each([
+    [
+      'push15',
+      'event_push_defbranch.env',
+      {
+        images: ['user/app'],
+        tags: [
+          `type=match,pattern=v(.*),group=1,value=v1.2.3`,
+          `type=edge`
+        ],
+      } as Inputs,
+      {
+        main: '1.2.3',
+        partial: ['edge'],
+        latest: true
+      } as Version,
+      [
+        'user/app:1.2.3',
+        'user/app:edge',
+        '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.2.3",
+        "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
+        "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
+        "org.opencontainers.image.licenses=MIT"
+      ]
+    ]
+  ])('given %p with %p event', tagsLabelsTest);
+});