Skip to content

Commit 8b842e7

Browse files
authored
Merge pull request #115 from crazy-max/edge-branch
Only return edge if branch matches
2 parents f6efe56 + 4cb9252 commit 8b842e7

File tree

4 files changed

+55
-33
lines changed

4 files changed

+55
-33
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,11 @@ Extended attributes and default values:
544544
```yaml
545545
tags: |
546546
# branch event
547-
type=ref,enable=true,priority=600,prefix=,suffix=,event=
547+
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
548548
# tag event
549-
type=ref,enable=true,priority=600,prefix=,suffix=,event=
549+
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
550550
# pull request event
551-
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=
551+
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr
552552
```
553553

554554
### `type=raw`

__tests__/meta.test.ts

+46-24
Original file line numberDiff line numberDiff line change
@@ -379,22 +379,20 @@ describe('push', () => {
379379
],
380380
} as Inputs,
381381
{
382-
main: 'master',
383-
partial: ['sha-90dd603'],
382+
main: 'sha-90dd603',
383+
partial: [],
384384
latest: false
385385
} as Version,
386386
[
387-
'org/app:master',
388387
'org/app:sha-90dd603',
389-
'ghcr.io/user/app:master',
390388
'ghcr.io/user/app:sha-90dd603'
391389
],
392390
[
393391
"org.opencontainers.image.title=Hello-World",
394392
"org.opencontainers.image.description=This your first repo!",
395393
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
396394
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
397-
"org.opencontainers.image.version=master",
395+
"org.opencontainers.image.version=sha-90dd603",
398396
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
399397
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
400398
"org.opencontainers.image.licenses=MIT"
@@ -411,22 +409,20 @@ describe('push', () => {
411409
],
412410
} as Inputs,
413411
{
414-
main: 'my-feature-1245',
415-
partial: ['sha-90dd603'],
412+
main: 'sha-90dd603',
413+
partial: [],
416414
latest: false
417415
} as Version,
418416
[
419-
'org/app:my-feature-1245',
420417
'org/app:sha-90dd603',
421-
'ghcr.io/user/app:my-feature-1245',
422418
'ghcr.io/user/app:sha-90dd603'
423419
],
424420
[
425421
"org.opencontainers.image.title=Hello-World",
426422
"org.opencontainers.image.description=This your first repo!",
427423
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
428424
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
429-
"org.opencontainers.image.version=my-feature-1245",
425+
"org.opencontainers.image.version=sha-90dd603",
430426
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
431427
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
432428
"org.opencontainers.image.licenses=MIT"
@@ -444,20 +440,17 @@ describe('push', () => {
444440
],
445441
} as Inputs,
446442
{
447-
main: 'my-feature-1245',
443+
main: undefined,
448444
partial: [],
449445
latest: false
450446
} as Version,
451-
[
452-
'org/app:my-feature-1245',
453-
'ghcr.io/user/app:my-feature-1245'
454-
],
447+
[],
455448
[
456449
"org.opencontainers.image.title=Hello-World",
457450
"org.opencontainers.image.description=This your first repo!",
458451
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
459452
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
460-
"org.opencontainers.image.version=my-feature-1245",
453+
"org.opencontainers.image.version=",
461454
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
462455
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
463456
"org.opencontainers.image.licenses=MIT"
@@ -646,6 +639,37 @@ describe('push', () => {
646639
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
647640
"org.opencontainers.image.licenses=MIT"
648641
]
642+
],
643+
[
644+
'push19',
645+
'event_push.env',
646+
{
647+
images: ['org/app', 'ghcr.io/user/app'],
648+
tags: [
649+
`type=edge,branch=master`,
650+
`type=ref,event=branch,enable=false`,
651+
`type=sha,format=long`
652+
],
653+
} as Inputs,
654+
{
655+
main: 'sha-90dd6032fac8bda1b6c4436a2e65de27961ed071',
656+
partial: [],
657+
latest: false
658+
} as Version,
659+
[
660+
'org/app:sha-90dd6032fac8bda1b6c4436a2e65de27961ed071',
661+
'ghcr.io/user/app:sha-90dd6032fac8bda1b6c4436a2e65de27961ed071'
662+
],
663+
[
664+
"org.opencontainers.image.title=Hello-World",
665+
"org.opencontainers.image.description=This your first repo!",
666+
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
667+
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
668+
"org.opencontainers.image.version=sha-90dd6032fac8bda1b6c4436a2e65de27961ed071",
669+
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
670+
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
671+
"org.opencontainers.image.licenses=MIT"
672+
]
649673
]
650674
])('given %p with %p event', tagsLabelsTest);
651675
});
@@ -1377,28 +1401,26 @@ describe('tag', () => {
13771401
{
13781402
images: ['org/app'],
13791403
tags: [
1380-
`type=pep440,pattern={{version}}`,
1381-
`type=pep440,pattern={{major}}.{{minor}}`,
1382-
`type=pep440,pattern={{major}}`
1404+
`type=pep440,pattern={{raw}}`,
1405+
`type=pep440,pattern={{major}}.{{minor}}`
13831406
]
13841407
} as Inputs,
13851408
{
1386-
main: '1.1.1',
1387-
partial: ['1.1', '1'],
1409+
main: 'v1.1.1',
1410+
partial: ['1.1'],
13881411
latest: true
13891412
} as Version,
13901413
[
1391-
'org/app:1.1.1',
1414+
'org/app:v1.1.1',
13921415
'org/app:1.1',
1393-
'org/app:1',
13941416
'org/app:latest'
13951417
],
13961418
[
13971419
"org.opencontainers.image.title=Hello-World",
13981420
"org.opencontainers.image.description=This your first repo!",
13991421
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
14001422
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
1401-
"org.opencontainers.image.version=1.1.1",
1423+
"org.opencontainers.image.version=v1.1.1",
14021424
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
14031425
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
14041426
"org.opencontainers.image.licenses=MIT"

dist/index.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/meta.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ export class Meta {
265265
if (tag.attrs['branch'].length == 0) {
266266
tag.attrs['branch'] = this.repo.default_branch;
267267
}
268-
if (tag.attrs['branch'] === val) {
269-
val = 'edge';
268+
if (tag.attrs['branch'] != val) {
269+
return version;
270270
}
271271

272-
const vraw = this.setValue(val, tag);
272+
const vraw = this.setValue('edge', tag);
273273
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
274274
}
275275

0 commit comments

Comments
 (0)