Add format attribute for type=sha

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-05-11 20:14:23 +02:00
parent 2af9c6a52b
commit 8841ef4bb7
6 changed files with 111 additions and 11 deletions

View File

@ -617,7 +617,39 @@ describe('push', () => {
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
]
],
[
'push18',
'event_push.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=ref,event=branch`,
`type=sha,format=long`
],
} as Inputs,
{
main: 'dev',
partial: ['sha-90dd6032fac8bda1b6c4436a2e65de27961ed071'],
latest: false
} as Version,
[
'org/app:dev',
'org/app:sha-90dd6032fac8bda1b6c4436a2e65de27961ed071',
'ghcr.io/user/app:dev',
'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=dev",
"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);
});

View File

@ -1,4 +1,4 @@
import {Transform, Parse, Tag, Type, RefEvent, DefaultPriorities} from '../src/tag';
import {Transform, Parse, Tag, Type, RefEvent, ShaFormat, DefaultPriorities} from '../src/tag';
describe('transform', () => {
// prettier-ignore
@ -89,7 +89,8 @@ describe('transform', () => {
attrs: {
"priority": DefaultPriorities[Type.Sha],
"enable": "true",
"prefix": "sha-"
"prefix": "sha-",
"format": ShaFormat.Short
}
}
] as Tag[],
@ -355,7 +356,21 @@ describe('parse', () => {
attrs: {
"priority": DefaultPriorities[Type.Sha],
"enable": "true",
"prefix": "sha-"
"prefix": "sha-",
"format": ShaFormat.Short
}
} as Tag,
false
],
[
`type=sha,format=long`,
{
type: Type.Sha,
attrs: {
"priority": DefaultPriorities[Type.Sha],
"enable": "true",
"prefix": "sha-",
"format": ShaFormat.Long
}
} as Tag,
false
@ -367,7 +382,8 @@ describe('parse', () => {
attrs: {
"priority": DefaultPriorities[Type.Sha],
"enable": "true",
"prefix": ""
"prefix": "",
"format": ShaFormat.Short
}
} as Tag,
false
@ -379,7 +395,8 @@ describe('parse', () => {
attrs: {
"priority": DefaultPriorities[Type.Sha],
"enable": "false",
"prefix": "sha-"
"prefix": "sha-",
"format": ShaFormat.Short
}
} as Tag,
false
@ -403,6 +420,11 @@ describe('parse', () => {
`type=sha,enable=foo`,
{} as Tag,
true
],
[
`type=sha,format=foo`,
{} as Tag,
true
]
])('given %p event ', async (s: string, expected: Tag, invalid: boolean) => {
try {