Skip to content

Commit

Permalink
Merge pull request #115 from crazy-max/edge-branch
Browse files Browse the repository at this point in the history
Only return edge if branch matches
  • Loading branch information
crazy-max committed Jul 14, 2021
2 parents f6efe56 + 4cb9252 commit 8b842e7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 33 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -544,11 +544,11 @@ Extended attributes and default values:
```yaml
tags: |
# branch event
type=ref,enable=true,priority=600,prefix=,suffix=,event=
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
# tag event
type=ref,enable=true,priority=600,prefix=,suffix=,event=
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
# pull request event
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr
```
### `type=raw`
Expand Down
70 changes: 46 additions & 24 deletions __tests__/meta.test.ts
Expand Up @@ -379,22 +379,20 @@ describe('push', () => {
],
} as Inputs,
{
main: 'master',
partial: ['sha-90dd603'],
main: 'sha-90dd603',
partial: [],
latest: false
} as Version,
[
'org/app:master',
'org/app:sha-90dd603',
'ghcr.io/user/app:master',
'ghcr.io/user/app:sha-90dd603'
],
[
"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=master",
"org.opencontainers.image.version=sha-90dd603",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
Expand All @@ -411,22 +409,20 @@ describe('push', () => {
],
} as Inputs,
{
main: 'my-feature-1245',
partial: ['sha-90dd603'],
main: 'sha-90dd603',
partial: [],
latest: false
} as Version,
[
'org/app:my-feature-1245',
'org/app:sha-90dd603',
'ghcr.io/user/app:my-feature-1245',
'ghcr.io/user/app:sha-90dd603'
],
[
"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=my-feature-1245",
"org.opencontainers.image.version=sha-90dd603",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
Expand All @@ -444,20 +440,17 @@ describe('push', () => {
],
} as Inputs,
{
main: 'my-feature-1245',
main: undefined,
partial: [],
latest: false
} as Version,
[
'org/app:my-feature-1245',
'ghcr.io/user/app:my-feature-1245'
],
[],
[
"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=my-feature-1245",
"org.opencontainers.image.version=",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
Expand Down Expand Up @@ -646,6 +639,37 @@ describe('push', () => {
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
],
[
'push19',
'event_push.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=edge,branch=master`,
`type=ref,event=branch,enable=false`,
`type=sha,format=long`
],
} as Inputs,
{
main: 'sha-90dd6032fac8bda1b6c4436a2e65de27961ed071',
partial: [],
latest: false
} as Version,
[
'org/app:sha-90dd6032fac8bda1b6c4436a2e65de27961ed071',
'ghcr.io/user/app:sha-90dd6032fac8bda1b6c4436a2e65de27961ed071'
],
[
"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=sha-90dd6032fac8bda1b6c4436a2e65de27961ed071",
"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);
});
Expand Down Expand Up @@ -1377,28 +1401,26 @@ describe('tag', () => {
{
images: ['org/app'],
tags: [
`type=pep440,pattern={{version}}`,
`type=pep440,pattern={{major}}.{{minor}}`,
`type=pep440,pattern={{major}}`
`type=pep440,pattern={{raw}}`,
`type=pep440,pattern={{major}}.{{minor}}`
]
} as Inputs,
{
main: '1.1.1',
partial: ['1.1', '1'],
main: 'v1.1.1',
partial: ['1.1'],
latest: true
} as Version,
[
'org/app:1.1.1',
'org/app:v1.1.1',
'org/app:1.1',
'org/app:1',
'org/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.version=v1.1.1",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
Expand Down
6 changes: 3 additions & 3 deletions dist/index.js

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

6 changes: 3 additions & 3 deletions src/meta.ts
Expand Up @@ -265,11 +265,11 @@ export class Meta {
if (tag.attrs['branch'].length == 0) {
tag.attrs['branch'] = this.repo.default_branch;
}
if (tag.attrs['branch'] === val) {
val = 'edge';
if (tag.attrs['branch'] != val) {
return version;
}

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

Expand Down

0 comments on commit 8b842e7

Please sign in to comment.