is_default_branch global expression
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
7 files changed
+179
-40
No files matched your search
@@ -32,6 +32,12 @@ ___
|
|||||||
* [Notes](#notes)
|
* [Notes](#notes)
|
||||||
* [Latest tag](#latest-tag)
|
* [Latest tag](#latest-tag)
|
||||||
* [Global expressions](#global-expressions)
|
* [Global expressions](#global-expressions)
|
||||||
|
* [`{{branch}}`](#branch)
|
||||||
|
* [`{{tag}}`](#tag)
|
||||||
|
* [`{{sha}}`](#sha)
|
||||||
|
* [`{{base_ref}}`](#base_ref)
|
||||||
|
* [`{{is_default_branch}}`](#is_default_branch)
|
||||||
|
* [`{{date '<format>'}}`](#date-format)
|
||||||
* [Major version zero](#major-version-zero)
|
* [Major version zero](#major-version-zero)
|
||||||
* [JSON output object](#json-output-object)
|
* [JSON output object](#json-output-object)
|
||||||
* [Overwrite labels](#overwrite-labels)
|
* [Overwrite labels](#overwrite-labels)
|
||||||
@@ -232,7 +238,7 @@ Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with `
|
|||||||
"org.opencontainers.image.source": "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.version": "1.2.3",
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
"org.opencontainers.image.revision": "860c1904a1ce19322e91ac35af1ab07466440c37",
|
||||||
"org.opencontainers.image.licenses": "MIT"
|
"org.opencontainers.image.licenses": "MIT"
|
||||||
},
|
},
|
||||||
"args": {
|
"args": {
|
||||||
@@ -605,26 +611,28 @@ tags: |
|
|||||||
* [`type=semver,pattern=...`](#typesemver)
|
* [`type=semver,pattern=...`](#typesemver)
|
||||||
* [`type=match,pattern=...`](#typematch)
|
* [`type=match,pattern=...`](#typematch)
|
||||||
|
|
||||||
For conditionally tagging with latest for a specific branch name, e.g. if your default branch name
|
For conditionally tagging with latest for a specific branch name, e.g. if your
|
||||||
is not `master`, use `type=raw` with a boolean expression:
|
default branch name is not `master`, use `type=raw` with a boolean expression:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
|
# set latest tag for master branch
|
||||||
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use the [`{{is_default_branch}}` global expression](#is_default_branch)
|
||||||
|
to conditionally tag with latest for the default branch:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# set latest tag for default branch
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Global expressions
|
### Global expressions
|
||||||
|
|
||||||
The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value`
|
The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions
|
||||||
attributes are available:
|
for `prefix`, `suffix`, `value` and `enable` attributes are available:
|
||||||
|
|
||||||
| Expression | Output |
|
|
||||||
|--------------------------|----------------------|
|
|
||||||
| `{{branch}}` | `master` |
|
|
||||||
| `{{tag}}` | `v1.2.3` |
|
|
||||||
| `{{sha}}` | `90dd603` |
|
|
||||||
| `{{base_ref}}` | `master` |
|
|
||||||
| `{{date 'YYYYMMDD'}}` | `20210326` |
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
tags: |
|
tags: |
|
||||||
@@ -634,6 +642,63 @@ tags: |
|
|||||||
type=raw,value=mytag-{{branch}}-{{sha}}
|
type=raw,value=mytag-{{branch}}-{{sha}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `{{branch}}`
|
||||||
|
|
||||||
|
Returns the branch name that triggered the workflow run. Will be empty if not
|
||||||
|
a branch reference:
|
||||||
|
|
||||||
|
| Event | Ref | Output |
|
||||||
|
|-----------------|-------------------------------|---------------------|
|
||||||
|
| `pull_request` | `refs/pull/2/merge` | |
|
||||||
|
| `push` | `refs/heads/master` | `master` |
|
||||||
|
| `push` | `refs/heads/my/branch` | `my-branch` |
|
||||||
|
| `push tag` | `refs/tags/v1.2.3` | |
|
||||||
|
|
||||||
|
#### `{{tag}}`
|
||||||
|
|
||||||
|
Returns the tag name that triggered the workflow run. Will be empty if not a
|
||||||
|
tag reference:
|
||||||
|
|
||||||
|
| Event | Ref | Output |
|
||||||
|
|-----------------|-------------------------------|--------------------|
|
||||||
|
| `pull_request` | `refs/pull/2/merge` | |
|
||||||
|
| `push` | `refs/heads/master` | |
|
||||||
|
| `push` | `refs/heads/my/branch` | |
|
||||||
|
| `push tag` | `refs/tags/v1.2.3` | `v1.2.3` |
|
||||||
|
|
||||||
|
#### `{{sha}}`
|
||||||
|
|
||||||
|
Returns the short commit SHA that triggered the workflow run (e.g., `90dd603`).
|
||||||
|
|
||||||
|
#### `{{base_ref}}`
|
||||||
|
|
||||||
|
Returns the base ref or target branch of the pull request that triggered the
|
||||||
|
workflow run. Will be empty for a branch reference:
|
||||||
|
|
||||||
|
| Event | Ref | Output |
|
||||||
|
|-----------------|-------------------------------|--------------------|
|
||||||
|
| `pull_request` | `refs/pull/2/merge` | `master` |
|
||||||
|
| `push` | `refs/heads/master` | |
|
||||||
|
| `push` | `refs/heads/my/branch` | |
|
||||||
|
| `push tag` | `refs/tags/v1.2.3` | `master` |
|
||||||
|
|
||||||
|
#### `{{is_default_branch}}`
|
||||||
|
|
||||||
|
Returns `true` if the branch that triggered the workflow run is the default
|
||||||
|
one, otherwise `false`.
|
||||||
|
|
||||||
|
Will compare against the branch name that triggered the workflow run or the
|
||||||
|
base ref or target branch for a pull request or a tag.
|
||||||
|
|
||||||
|
#### `{{date '<format>'}}`
|
||||||
|
|
||||||
|
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
||||||
|
|
||||||
|
| Expression | Output example |
|
||||||
|
|--------------------------------------------|-----------------------------------------|
|
||||||
|
| `{{date 'YYYYMMDD'}}` | `20200110` |
|
||||||
|
| `{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
|
||||||
|
|
||||||
### Major version zero
|
### Major version zero
|
||||||
|
|
||||||
Major version zero (`0.y.z`) is for initial development and **may** change at any time. This means the public API
|
Major version zero (`0.y.z`) is for initial development and **may** change at any time. This means the public API
|
||||||
|
|||||||
+71
-15
@@ -598,7 +598,8 @@ describe('push', () => {
|
|||||||
`type=raw,value=mytag-{{branch}}`,
|
`type=raw,value=mytag-{{branch}}`,
|
||||||
`type=raw,value=mytag-{{date 'YYYYMMDD'}}`,
|
`type=raw,value=mytag-{{date 'YYYYMMDD'}}`,
|
||||||
`type=raw,value=mytag-tag-{{tag}}`,
|
`type=raw,value=mytag-tag-{{tag}}`,
|
||||||
`type=raw,value=mytag-baseref-{{base_ref}}`
|
`type=raw,value=mytag-baseref-{{base_ref}}`,
|
||||||
|
`type=raw,value=mytag-defbranch,enable={{is_default_branch}}`
|
||||||
],
|
],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
@@ -606,7 +607,8 @@ describe('push', () => {
|
|||||||
partial: [
|
partial: [
|
||||||
'mytag-20200110',
|
'mytag-20200110',
|
||||||
'mytag-tag-',
|
'mytag-tag-',
|
||||||
'mytag-baseref-'
|
'mytag-baseref-',
|
||||||
|
'mytag-defbranch'
|
||||||
],
|
],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
@@ -614,7 +616,8 @@ describe('push', () => {
|
|||||||
'user/app:mytag-master',
|
'user/app:mytag-master',
|
||||||
'user/app:mytag-20200110',
|
'user/app:mytag-20200110',
|
||||||
'user/app:mytag-tag-',
|
'user/app:mytag-tag-',
|
||||||
'user/app:mytag-baseref-'
|
'user/app:mytag-baseref-',
|
||||||
|
'user/app:mytag-defbranch'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"org.opencontainers.image.title=Hello-World",
|
"org.opencontainers.image.title=Hello-World",
|
||||||
@@ -667,7 +670,8 @@ describe('push', () => {
|
|||||||
tags: [
|
tags: [
|
||||||
`type=edge,branch=master`,
|
`type=edge,branch=master`,
|
||||||
`type=ref,event=branch,enable=false`,
|
`type=ref,event=branch,enable=false`,
|
||||||
`type=sha,format=long`
|
`type=sha,format=long`,
|
||||||
|
`type=raw,value=defbranch,enable={{is_default_branch}}`
|
||||||
],
|
],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
@@ -1321,21 +1325,25 @@ describe('tag', () => {
|
|||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
tags: [
|
tags: [
|
||||||
`type=raw,{{tag}}-{{sha}}-foo`,
|
`type=raw,{{tag}}-{{sha}}-foo`,
|
||||||
`type=raw,{{base_ref}}-foo`
|
`type=raw,{{base_ref}}-foo`,
|
||||||
|
`type=raw,defbranch-foo,enable={{is_default_branch}}`
|
||||||
]
|
]
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: 'v1.1.1-860c190-foo',
|
main: 'v1.1.1-860c190-foo',
|
||||||
partial: [
|
partial: [
|
||||||
'master-foo'
|
'master-foo',
|
||||||
|
'defbranch-foo'
|
||||||
],
|
],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'org/app:v1.1.1-860c190-foo',
|
'org/app:v1.1.1-860c190-foo',
|
||||||
'org/app:master-foo',
|
'org/app:master-foo',
|
||||||
|
'org/app:defbranch-foo',
|
||||||
'ghcr.io/user/app:v1.1.1-860c190-foo',
|
'ghcr.io/user/app:v1.1.1-860c190-foo',
|
||||||
'ghcr.io/user/app:master-foo'
|
'ghcr.io/user/app:master-foo',
|
||||||
|
'ghcr.io/user/app:defbranch-foo'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"org.opencontainers.image.title=Hello-World",
|
"org.opencontainers.image.title=Hello-World",
|
||||||
@@ -2317,15 +2325,19 @@ describe('pr', () => {
|
|||||||
images: ['org/app'],
|
images: ['org/app'],
|
||||||
tags: [
|
tags: [
|
||||||
`type=raw,value=mytag-{{base_ref}}`,
|
`type=raw,value=mytag-{{base_ref}}`,
|
||||||
|
`type=raw,mytag-defbranch,enable={{is_default_branch}}`
|
||||||
]
|
]
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: 'mytag-master',
|
main: 'mytag-master',
|
||||||
partial: [],
|
partial: [
|
||||||
|
'mytag-defbranch'
|
||||||
|
],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'org/app:mytag-master'
|
'org/app:mytag-master',
|
||||||
|
'org/app:mytag-defbranch'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"org.opencontainers.image.title=Hello-World",
|
"org.opencontainers.image.title=Hello-World",
|
||||||
@@ -2339,21 +2351,25 @@ describe('pr', () => {
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'pr06',
|
'pr11',
|
||||||
'event_pull_request.env',
|
'event_pull_request.env',
|
||||||
{
|
{
|
||||||
images: ['org/app'],
|
images: ['org/app'],
|
||||||
tags: [
|
tags: [
|
||||||
`type=raw,value=mytag-{{base_ref}}`,
|
`type=raw,value=mytag-{{base_ref}}`,
|
||||||
|
`type=raw,mytag-defbranch,enable={{is_default_branch}}`
|
||||||
]
|
]
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: 'mytag-master',
|
main: 'mytag-master',
|
||||||
partial: [],
|
partial: [
|
||||||
|
'mytag-defbranch'
|
||||||
|
],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'org/app:mytag-master'
|
'org/app:mytag-master',
|
||||||
|
'org/app:mytag-defbranch'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"org.opencontainers.image.title=Hello-World",
|
"org.opencontainers.image.title=Hello-World",
|
||||||
@@ -2521,19 +2537,25 @@ describe('schedule', () => {
|
|||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
tags: [
|
tags: [
|
||||||
`type=schedule`,
|
`type=schedule`,
|
||||||
`type=sha,priority=2000`
|
`type=sha,priority=2000`,
|
||||||
|
`type=raw,value=defbranch,enable={{is_default_branch}}`
|
||||||
]
|
]
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: 'sha-860c190',
|
main: 'sha-860c190',
|
||||||
partial: ['nightly'],
|
partial: [
|
||||||
|
'nightly',
|
||||||
|
'defbranch'
|
||||||
|
],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'org/app:sha-860c190',
|
'org/app:sha-860c190',
|
||||||
'org/app:nightly',
|
'org/app:nightly',
|
||||||
|
'org/app:defbranch',
|
||||||
'ghcr.io/user/app:sha-860c190',
|
'ghcr.io/user/app:sha-860c190',
|
||||||
'ghcr.io/user/app:nightly'
|
'ghcr.io/user/app:nightly',
|
||||||
|
'ghcr.io/user/app:defbranch'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"org.opencontainers.image.title=Hello-World",
|
"org.opencontainers.image.title=Hello-World",
|
||||||
@@ -2611,6 +2633,40 @@ describe('release', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'release02',
|
||||||
|
'event_release_created.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
tags: [
|
||||||
|
`type=ref,event=tag`,
|
||||||
|
`type=raw,value=baseref-{{base_ref}}`,
|
||||||
|
`type=raw,value=defbranch,enable={{is_default_branch}}`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'v1.1.1',
|
||||||
|
partial: [
|
||||||
|
'baseref-'
|
||||||
|
],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:v1.1.1',
|
||||||
|
'user/app:baseref-',
|
||||||
|
'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=v1.1.1",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
]
|
||||||
])('given %s with %p event', tagsLabelsTest);
|
])('given %s with %p event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -417,11 +417,6 @@ describe('parse', () => {
|
|||||||
{} as Tag,
|
{} as Tag,
|
||||||
true
|
true
|
||||||
],
|
],
|
||||||
[
|
|
||||||
`type=sha,enable=foo`,
|
|
||||||
{} as Tag,
|
|
||||||
true
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
`type=sha,format=foo`,
|
`type=sha,format=foo`,
|
||||||
{} as Tag,
|
{} as Tag,
|
||||||
|
|||||||
+1
-1
@@ -56,5 +56,5 @@ hooks.version="2.29.3";setHookCallback(createLocal);hooks.fn=We;hooks.min=min;ho
|
|||||||
* XRegExp 4.4.1
|
* XRegExp 4.4.1
|
||||||
* <xregexp.com>
|
* <xregexp.com>
|
||||||
* Steven Levithan (c) 2007-present MIT License
|
* Steven Levithan (c) 2007-present MIT License
|
||||||
*/var T="xregexp";var k={astral:false,namespacing:false};var O={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split};var P={};var x={};var A={};var D=[];var N="default";var C="class";var I={default:/\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,class:/\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/};var R=/\$(?:{([\w$]+)}|<([\w$]+)>|(\d\d?|[\s\S]))/g;var L=O.exec.call(/()??/,"")[1]===undefined;var M=(0,E["default"])(/x/)!==undefined;var G={},V=G.toString;function hasNativeFlag(t){var a=true;try{new RegExp("",t);if(t==="y"){var r=function(){return"gy"}();var d=".a".replace(new RegExp("a",r),".")==="..";if(d){a=false}}}catch(t){a=false}return a}var U=hasNativeFlag("u");var j=hasNativeFlag("y");var B={g:true,i:true,m:true,u:U,y:j};function augment(t,a,r,d,i){var o;t[T]={captureNames:a};if(i){return t}if(t.__proto__){t.__proto__=XRegExp.prototype}else{for(var p in XRegExp.prototype){t[p]=XRegExp.prototype[p]}}t[T].source=r;t[T].flags=d?(0,S["default"])(o=d.split("")).call(o).join(""):d;return t}function clipDuplicates(t){return O.replace.call(t,/([\s\S])(?=[\s\S]*\1)/g,"")}function copyRegex(t,a){var r;if(!XRegExp.isRegExp(t)){throw new TypeError("Type RegExp expected")}var d=t[T]||{};var i=getNativeFlags(t);var o="";var p="";var u=null;var l=null;a=a||{};if(a.removeG){p+="g"}if(a.removeY){p+="y"}if(p){i=O.replace.call(i,new RegExp("[".concat(p,"]+"),"g"),"")}if(a.addG){o+="g"}if(a.addY){o+="y"}if(o){i=clipDuplicates(i+o)}if(!a.isInternalOnly){if(d.source!==undefined){u=d.source}if((0,E["default"])(d)!=null){l=o?clipDuplicates((0,E["default"])(d)+o):(0,E["default"])(d)}}t=augment(new RegExp(a.source||t.source,i),hasNamedCapture(t)?(0,y["default"])(r=d.captureNames).call(r,0):null,u,l,a.isInternalOnly);return t}function dec(t){return(0,w["default"])(t,16)}function getContextualTokenSeparator(t,a,r){if(t.input[t.index-1]==="("||t.input[t.index+t[0].length]===")"||t.input[t.index-1]==="|"||t.input[t.index+t[0].length]==="|"||t.index<1||t.index+t[0].length>=t.input.length||O.test.call(/^\(\?[:=!]/,t.input.substr(t.index-3,3))||isQuantifierNext(t.input,t.index+t[0].length,r)){return""}return"(?:)"}function getNativeFlags(t){return M?(0,E["default"])(t):O.exec.call(/\/([a-z]*)$/i,RegExp.prototype.toString.call(t))[1]}function hasNamedCapture(t){return!!(t[T]&&t[T].captureNames)}function hex(t){return(0,w["default"])(t,10).toString(16)}function isQuantifierNext(t,a,r){var d="\\(\\?#[^)]*\\)";var i="#[^#\\n]*";var o="[?*+]|{\\d+(?:,\\d*)?}";return O.test.call((0,b["default"])(r).call(r,"x")?/^(?:\s|#[^#\n]*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/:/^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/,(0,y["default"])(t).call(t,a))}function isType(t,a){return V.call(t)==="[object ".concat(a,"]")}function pad4(t){while(t.length<4){t="0".concat(t)}return t}function prepareFlags(t,a){if(clipDuplicates(a)!==a){throw new SyntaxError("Invalid duplicate regex flag ".concat(a))}t=O.replace.call(t,/^\(\?([\w$]+)\)/,(function(t,r){if(O.test.call(/[gy]/,r)){throw new SyntaxError("Cannot use flag g or y in mode modifier ".concat(t))}a=clipDuplicates(a+r);return""}));var r=_createForOfIteratorHelper(a),d;try{for(r.s();!(d=r.n()).done;){var i=d.value;if(!B[i]){throw new SyntaxError("Unknown regex flag ".concat(i))}}}catch(t){r.e(t)}finally{r.f()}return{pattern:t,flags:a}}function prepareOptions(t){var a={};if(isType(t,"String")){(0,_["default"])(XRegExp).call(XRegExp,t,/[^\s,]+/,(function(t){a[t]=true}));return a}return t}function registerFlag(t){if(!/^[\w$]$/.test(t)){throw new Error("Flag must be a single character A-Za-z0-9_$")}B[t]=true}function runTokens(t,a,r,d,i){var o=D.length;var p=t[r];var u=null;var l;var c;while(o--){c=D[o];if(c.leadChar&&c.leadChar!==p||c.scope!==d&&c.scope!=="all"||c.flag&&!(0,b["default"])(a).call(a,c.flag)){continue}l=XRegExp.exec(t,c.regex,r,"sticky");if(l){u={matchLength:l[0].length,output:c.handler.call(i,l,d,a),reparse:c.reparse};break}}return u}function setAstral(t){k.astral=t}function setNamespacing(t){k.namespacing=t}function toObject(t){if(t==null){throw new TypeError("Cannot convert null or undefined to object")}return t}function XRegExp(t,a){if(XRegExp.isRegExp(t)){if(a!==undefined){throw new TypeError("Cannot supply flags when copying a RegExp")}return copyRegex(t)}t=t===undefined?"":String(t);a=a===undefined?"":String(a);if(XRegExp.isInstalled("astral")&&!(0,b["default"])(a).call(a,"A")){a+="A"}if(!A[t]){A[t]={}}if(!A[t][a]){var r={hasNamedCapture:false,captureNames:[]};var d=N;var i="";var o=0;var p;var u=prepareFlags(t,a);var l=u.pattern;var c=(0,E["default"])(u);while(o<l.length){do{p=runTokens(l,c,o,d,r);if(p&&p.reparse){l=(0,y["default"])(l).call(l,0,o)+p.output+(0,y["default"])(l).call(l,o+p.matchLength)}}while(p&&p.reparsLine truncated
|
*/var T="xregexp";var k={astral:false,namespacing:false};var O={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split};var P={};var x={};var A={};var D=[];var N="default";var C="class";var I={default:/\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,class:/\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/};var R=/\$(?:{([\w$]+)}|<([\w$]+)>|(\d\d?|[\s\S]))/g;var L=O.exec.call(/()??/,"")[1]===undefined;var M=(0,E["default"])(/x/)!==undefined;var G={},V=G.toString;function hasNativeFlag(t){var a=true;try{new RegExp("",t);if(t==="y"){var r=function(){return"gy"}();var d=".a".replace(new RegExp("a",r),".")==="..";if(d){a=false}}}catch(t){a=false}return a}var U=hasNativeFlag("u");var j=hasNativeFlag("y");var B={g:true,i:true,m:true,u:U,y:j};function augment(t,a,r,d,i){var o;t[T]={captureNames:a};if(i){return t}if(t.__proto__){t.__proto__=XRegExp.prototype}else{for(var p in XRegExp.prototype){t[p]=XRegExp.prototype[p]}}t[T].source=r;t[T].flags=d?(0,S["default"])(o=d.split("")).call(o).join(""):d;return t}function clipDuplicates(t){return O.replace.call(t,/([\s\S])(?=[\s\S]*\1)/g,"")}function copyRegex(t,a){var r;if(!XRegExp.isRegExp(t)){throw new TypeError("Type RegExp expected")}var d=t[T]||{};var i=getNativeFlags(t);var o="";var p="";var u=null;var l=null;a=a||{};if(a.removeG){p+="g"}if(a.removeY){p+="y"}if(p){i=O.replace.call(i,new RegExp("[".concat(p,"]+"),"g"),"")}if(a.addG){o+="g"}if(a.addY){o+="y"}if(o){i=clipDuplicates(i+o)}if(!a.isInternalOnly){if(d.source!==undefined){u=d.source}if((0,E["default"])(d)!=null){l=o?clipDuplicates((0,E["default"])(d)+o):(0,E["default"])(d)}}t=augment(new RegExp(a.source||t.source,i),hasNamedCapture(t)?(0,y["default"])(r=d.captureNames).call(r,0):null,u,l,a.isInternalOnly);return t}function dec(t){return(0,w["default"])(t,16)}function getContextualTokenSeparator(t,a,r){if(t.input[t.index-1]==="("||t.input[t.index+t[0].length]===")"||t.input[t.index-1]==="|"||t.input[t.index+t[0].length]==="|"||t.index<1||t.index+t[0].length>=t.input.length||O.test.call(/^\(\?[:=!]/,t.input.substr(t.index-3,3))||isQuantifierNext(t.input,t.index+t[0].length,r)){return""}return"(?:)"}function getNativeFlags(t){return M?(0,E["default"])(t):O.exec.call(/\/([a-z]*)$/i,RegExp.prototype.toString.call(t))[1]}function hasNamedCapture(t){return!!(t[T]&&t[T].captureNames)}function hex(t){return(0,w["default"])(t,10).toString(16)}function isQuantifierNext(t,a,r){var d="\\(\\?#[^)]*\\)";var i="#[^#\\n]*";var o="[?*+]|{\\d+(?:,\\d*)?}";return O.test.call((0,b["default"])(r).call(r,"x")?/^(?:\s|#[^#\n]*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/:/^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/,(0,y["default"])(t).call(t,a))}function isType(t,a){return V.call(t)==="[object ".concat(a,"]")}function pad4(t){while(t.length<4){t="0".concat(t)}return t}function prepareFlags(t,a){if(clipDuplicates(a)!==a){throw new SyntaxError("Invalid duplicate regex flag ".concat(a))}t=O.replace.call(t,/^\(\?([\w$]+)\)/,(function(t,r){if(O.test.call(/[gy]/,r)){throw new SyntaxError("Cannot use flag g or y in mode modifier ".concat(t))}a=clipDuplicates(a+r);return""}));var r=_createForOfIteratorHelper(a),d;try{for(r.s();!(d=r.n()).done;){var i=d.value;if(!B[i]){throw new SyntaxError("Unknown regex flag ".concat(i))}}}catch(t){r.e(t)}finally{r.f()}return{pattern:t,flags:a}}function prepareOptions(t){var a={};if(isType(t,"String")){(0,_["default"])(XRegExp).call(XRegExp,t,/[^\s,]+/,(function(t){a[t]=true}));return a}return t}function registerFlag(t){if(!/^[\w$]$/.test(t)){throw new Error("Flag must be a single character A-Za-z0-9_$")}B[t]=true}function runTokens(t,a,r,d,i){var o=D.length;var p=t[r];var u=null;var l;var c;while(o--){c=D[o];if(c.leadChar&&c.leadChar!==p||c.scope!==d&&c.scope!=="all"||c.flag&&!(0,b["default"])(a).call(a,c.flag)){continue}l=XRegExp.exec(t,c.regex,r,"sticky");if(l){u={matchLength:l[0].length,output:c.handler.call(i,l,d,a),reparse:c.reparse};break}}return u}function setAstral(t){k.astral=t}function setNamespacing(t){k.namespacing=t}function toObject(t){if(t==null){throw new TypeError("Cannot convert null or undefined to object")}return t}function XRegExp(t,a){if(XRegExp.isRegExp(t)){if(a!==undefined){throw new TypeError("Cannot supply flags when copying a RegExp")}return copyRegex(t)}t=t===undefined?"":String(t);a=a===undefined?"":String(a);if(XRegExp.isInstalled("astral")&&!(0,b["default"])(a).call(a,"A")){a+="A"}if(!A[t]){A[t]={}}if(!A[t][a]){var r={hasNamedCapture:false,captureNames:[]};var d=N;var i="";var o=0;var p;var u=prepareFlags(t,a);var l=u.pattern;var c=(0,E["default"])(u);while(o<l.length){do{p=runTokens(l,c,o,d,r);if(p&&p.reparse){l=(0,y["default"])(l).call(l,0,o)+p.output+(0,y["default"])(l).call(l,o+p.matchLength)}}while(p&&p.reparsLine truncated
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../webpack:/docker-metadata-action/node_modules/@actions/core/lib/command.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/core.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/file-command.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/utils.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/context.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/github.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/internal/utils.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/utils.js","../webpack:/docker-metadata-action/node_modules/@actions/http-client/auth.js","../webpack:/docker-metadata-action/node_modules/@actions/http-client/index.js","../webpack:/docker-metadata-action/node_modules/@actions/http-client/proxy.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/array/from.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/array/is-array.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/flags.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/for-each.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/includes.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/index-of.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/map.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/reduce.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/slice.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/sort.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/object/create.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/object/define-property.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/parse-int.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/symbol.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/array/from.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/array/is-array.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/get-iterator-method.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/get-iterator.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/instance/slice.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/symbol.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/arrayLikeToArray.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/arrayWithHoles.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/interopRequireDefault.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/iterableToArrayLimit.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/nonIterableRest.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/slicedToArray.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/unsupportedIterableToArray.js","../webpack:/docker-metadata-action/node_modules/@octokit/auth-token/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/core/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/endpoint/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/graphql/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/graphql/node_modules/@octokit/request-error/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/graphql/node_modules/@octokit/request/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/request/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/request/node_modules/@octokit/request-error/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@renovate/pep440/index.js","../webpack:/docker-metadata-action/node_modLine truncated
|
{"version":3,"sources":["../webpack:/docker-metadata-action/node_modules/@actions/core/lib/command.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/core.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/file-command.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/docker-metadata-action/node_modules/@actions/core/lib/utils.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/context.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/github.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/internal/utils.js","../webpack:/docker-metadata-action/node_modules/@actions/github/lib/utils.js","../webpack:/docker-metadata-action/node_modules/@actions/http-client/auth.js","../webpack:/docker-metadata-action/node_modules/@actions/http-client/index.js","../webpack:/docker-metadata-action/node_modules/@actions/http-client/proxy.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/array/from.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/array/is-array.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/flags.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/for-each.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/includes.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/index-of.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/map.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/reduce.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/slice.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/instance/sort.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/object/create.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/object/define-property.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/parse-int.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js-stable/symbol.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/array/from.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/array/is-array.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/get-iterator-method.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/get-iterator.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/instance/slice.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/core-js/symbol.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/arrayLikeToArray.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/arrayWithHoles.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/interopRequireDefault.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/iterableToArrayLimit.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/nonIterableRest.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/slicedToArray.js","../webpack:/docker-metadata-action/node_modules/@babel/runtime-corejs3/helpers/unsupportedIterableToArray.js","../webpack:/docker-metadata-action/node_modules/@octokit/auth-token/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/core/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/endpoint/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/graphql/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/graphql/node_modules/@octokit/request-error/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/graphql/node_modules/@octokit/request/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/request/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@octokit/request/node_modules/@octokit/request-error/dist-node/index.js","../webpack:/docker-metadata-action/node_modules/@renovate/pep440/index.js","../webpack:/docker-metadata-action/node_modLine truncated
|
||||||
+27
-1
@@ -30,6 +30,7 @@ export class Meta {
|
|||||||
constructor(inputs: Inputs, context: Context, repo: ReposGetResponseData) {
|
constructor(inputs: Inputs, context: Context, repo: ReposGetResponseData) {
|
||||||
// Needs to override Git reference with pr ref instead of upstream branch ref
|
// Needs to override Git reference with pr ref instead of upstream branch ref
|
||||||
// for pull_request_target event
|
// for pull_request_target event
|
||||||
|
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
|
||||||
if (/pull_request_target/.test(context.eventName)) {
|
if (/pull_request_target/.test(context.eventName)) {
|
||||||
context.ref = `refs/pull/${context.payload.number}/merge`;
|
context.ref = `refs/pull/${context.payload.number}/merge`;
|
||||||
}
|
}
|
||||||
@@ -51,7 +52,11 @@ export class Meta {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const tag of this.tags) {
|
for (const tag of this.tags) {
|
||||||
if (!/true/i.test(tag.attrs['enable'])) {
|
const enabled = this.setGlobalExp(tag.attrs['enable']);
|
||||||
|
if (!['true', 'false'].includes(enabled)) {
|
||||||
|
throw new Error(`Invalid value for enable attribute: ${enabled}`);
|
||||||
|
}
|
||||||
|
if (!/true/i.test(enabled)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (tag.type) {
|
switch (tag.type) {
|
||||||
@@ -369,6 +374,27 @@ export class Meta {
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
is_default_branch: function () {
|
||||||
|
let branch = ctx.ref.replace(/^refs\/heads\//g, '');
|
||||||
|
if (/^refs\/tags\//.test(ctx.ref) && ctx.payload?.base_ref != undefined) {
|
||||||
|
branch = ctx.payload.base_ref.replace(/^refs\/heads\//g, '');
|
||||||
|
}
|
||||||
|
if (/^refs\/pull\//.test(ctx.ref) && ctx.payload?.pull_request?.base?.ref != undefined) {
|
||||||
|
branch = ctx.payload.pull_request.base.ref;
|
||||||
|
}
|
||||||
|
if (branch == undefined || branch.length == 0) {
|
||||||
|
return 'false';
|
||||||
|
}
|
||||||
|
if (ctx.payload?.repository?.default_branch == branch) {
|
||||||
|
return 'true';
|
||||||
|
}
|
||||||
|
// following events always trigger for last commit on default branch
|
||||||
|
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
|
||||||
|
if (/create/.test(ctx.eventName) || /discussion/.test(ctx.eventName) || /issues/.test(ctx.eventName) || /schedule/.test(ctx.eventName)) {
|
||||||
|
return 'true';
|
||||||
|
}
|
||||||
|
return 'false';
|
||||||
|
},
|
||||||
date: function (format) {
|
date: function (format) {
|
||||||
return moment(currentDate).utc().format(format);
|
return moment(currentDate).utc().format(format);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,9 +206,6 @@ export function Parse(s: string): Tag {
|
|||||||
if (!Object.prototype.hasOwnProperty.call(tag.attrs, 'priority')) {
|
if (!Object.prototype.hasOwnProperty.call(tag.attrs, 'priority')) {
|
||||||
tag.attrs['priority'] = DefaultPriorities[tag.type];
|
tag.attrs['priority'] = DefaultPriorities[tag.type];
|
||||||
}
|
}
|
||||||
if (!['true', 'false'].includes(tag.attrs['enable'])) {
|
|
||||||
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user