mirror of
https://code.forgejo.org/docker/metadata-action.git
synced 2025-08-12 00:50:53 +00:00
is_not_default_branch global expression
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
be19121bfd
commit
2bc3f4e0f1
4 changed files with 44 additions and 0 deletions
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -278,6 +278,7 @@ jobs:
|
|||
type=raw,value=gexp-tag-{{tag}}
|
||||
type=raw,value=gexp-baseref-{{base_ref}}
|
||||
type=raw,value=gexp-defbranch,enable={{is_default_branch}}
|
||||
type=raw,value=gexp-notdefbranch,enable={{is_not_default_branch}}
|
||||
|
||||
json:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -44,6 +44,7 @@ ___
|
|||
* [`{{sha}}`](#sha)
|
||||
* [`{{base_ref}}`](#base_ref)
|
||||
* [`{{is_default_branch}}`](#is_default_branch)
|
||||
* [`{{is_not_default_branch}}`](#is_not_default_branch)
|
||||
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
||||
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
|
||||
* [Major version zero](#major-version-zero)
|
||||
|
@ -874,6 +875,11 @@ workflow run. Will be empty for a branch reference:
|
|||
Returns `true` if the branch that triggered the workflow run is the default
|
||||
one, otherwise `false`.
|
||||
|
||||
#### `{{is_not_default_branch}}`
|
||||
|
||||
Returns `true` if the branch that triggered the workflow run is not the default
|
||||
one, otherwise `false`.
|
||||
|
||||
#### `{{date '<format>' tz='<timezone>'}}`
|
||||
|
||||
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
||||
|
|
|
@ -821,6 +821,40 @@ describe('push', () => {
|
|||
"org.opencontainers.image.version=mytag-master"
|
||||
],
|
||||
undefined
|
||||
],
|
||||
[
|
||||
'push22',
|
||||
'event_push_dev.env',
|
||||
{
|
||||
images: ['org/app'],
|
||||
tags: [
|
||||
`type=edge,branch=master`,
|
||||
`type=sha,format=long`,
|
||||
`type=raw,value=notdefbranch,enable={{is_not_default_branch}}`
|
||||
],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'notdefbranch',
|
||||
partial: [
|
||||
'sha-860c1904a1ce19322e91ac35af1ab07466440c37'
|
||||
],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
"org/app:notdefbranch",
|
||||
"org/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37"
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.licenses=MIT",
|
||||
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=notdefbranch"
|
||||
],
|
||||
undefined
|
||||
]
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
|
|
|
@ -439,6 +439,9 @@ export class Meta {
|
|||
}
|
||||
return 'false';
|
||||
},
|
||||
is_not_default_branch: function () {
|
||||
return this.is_default_branch() === 'false' ? 'true' : 'false';
|
||||
},
|
||||
date: function (format, options) {
|
||||
const m = moment(currentDate);
|
||||
let tz = 'UTC';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue