Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2e1a5c7fa4 | ||
|
1a678de43d | ||
|
84b9e75d44 | ||
|
f39f06a624 | ||
|
36ae18e02c | ||
|
e87dd9466c | ||
|
9da1e66de9 | ||
|
521a3c5ada | ||
|
7433b42479 | ||
|
1a8a264b95 | ||
|
e04b4d01a9 |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -72,9 +72,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- tag-match: '\d{1,3}.\d{1,3}.\d{1,3}'
|
||||
- tag-match: '\d.\d.\d'
|
||||
tag-match-group: '0'
|
||||
- tag-match: '\d{1,3}.\d{1,3}'
|
||||
- tag-match: '\d.\d'
|
||||
tag-match-group: '0'
|
||||
- tag-match: 'v(.*)'
|
||||
tag-match-group: '1'
|
||||
|
3
.github/workflows/label-sponsor.yml
vendored
3
.github/workflows/label-sponsor.yml
vendored
@@ -1,9 +1,6 @@
|
||||
name: label-sponsor
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- 'opened'
|
||||
issues:
|
||||
types:
|
||||
- 'opened'
|
||||
|
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,5 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## 2.3.0 (2021/04/07)
|
||||
|
||||
* Allow overriding flavor (#63)
|
||||
* Prefix/suffix not taken into account for `match`, `semver` and `schedule` types (#62)
|
||||
|
||||
## 2.2.1 (2021/04/05)
|
||||
|
||||
* Skip and display warning if tag does not match (#59)
|
||||
|
||||
## 2.2.0 (2021/04/03)
|
||||
|
||||
* Improve logging (#58)
|
||||
* Fix README (#56)
|
||||
|
||||
## 2.1.1 (2021/03/30)
|
||||
|
||||
* Fix `enable` tag attribute (#53)
|
||||
|
23
README.md
23
README.md
@@ -252,7 +252,7 @@ Following inputs can be used as `step.with` keys
|
||||
|
||||
> `List` type is a newline-delimited string
|
||||
> ```yaml
|
||||
> label-custom: |
|
||||
> labels: |
|
||||
> org.opencontainers.image.title=MyCustomTitle
|
||||
> org.opencontainers.image.description=Another description
|
||||
> org.opencontainers.image.vendor=MyCompany
|
||||
@@ -420,9 +420,7 @@ tags: |
|
||||
```yaml
|
||||
tags: |
|
||||
# minimal
|
||||
type=match,pattern=\d{8}
|
||||
# double quotes if comma in pattern
|
||||
type=match,"pattern=\d{1,3}.\d{1,3}.\d{1,3}"
|
||||
type=match,pattern=\d.\d.\d
|
||||
# define match group
|
||||
type=match,pattern=v(.*),group=1
|
||||
# use custom value instead of git tag
|
||||
@@ -435,16 +433,17 @@ a custom value through `value` attribute.
|
||||
|
||||
| Git tag | Pattern | Group | Output |
|
||||
|-------------------------|-------------------------------|---------|------------------------|
|
||||
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | `1.2.3` |
|
||||
| `v1.2.3` | `\d.\d.\d` | `0` | `1.2.3` |
|
||||
| `v2.0.8-beta.67` | `v(.*)` | `1` | `2.0.8-beta.67` |
|
||||
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | `2.0` |
|
||||
| `20200110-RC2` | `\d+` | `0` | `20200110` |
|
||||
| `p1/v1.2.3` | `p1-v(\d.\d.\d)` | `1` | `1.2.3` |
|
||||
|
||||
Extended attributes and default values:
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
type=group,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=
|
||||
type=match,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=
|
||||
```
|
||||
|
||||
### `type=edge`
|
||||
@@ -472,11 +471,11 @@ tags: |
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
# minimal branch event
|
||||
# branch event
|
||||
type=ref,event=branch
|
||||
# minimal tag event
|
||||
# tag event
|
||||
type=ref,event=tag
|
||||
# minimal pull request event
|
||||
# pull request event
|
||||
type=ref,event=pr
|
||||
```
|
||||
|
||||
@@ -497,11 +496,11 @@ Extended attributes and default values:
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
# event branch
|
||||
# branch event
|
||||
type=ref,enable=true,priority=600,prefix=,suffix=,event=
|
||||
# event tag
|
||||
# tag event
|
||||
type=ref,enable=true,priority=600,prefix=,suffix=,event=
|
||||
# event pr
|
||||
# pull request event
|
||||
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=
|
||||
```
|
||||
|
||||
|
23
__tests__/fixtures/event_tag_p1-v1.0.0.env
Normal file
23
__tests__/fixtures/event_tag_p1-v1.0.0.env
Normal file
@@ -0,0 +1,23 @@
|
||||
GITHUB_ACTION=crazy-maxghaction-dump-context
|
||||
GITHUB_ACTIONS=true
|
||||
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
|
||||
GITHUB_ACTOR=crazy-max
|
||||
GITHUB_API_URL=https://api.github.com
|
||||
GITHUB_BASE_REF=
|
||||
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
|
||||
GITHUB_EVENT_NAME=push
|
||||
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
|
||||
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
|
||||
GITHUB_HEAD_REF=
|
||||
GITHUB_JOB=event
|
||||
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
|
||||
GITHUB_REF=refs/tags/p1/v1.0.0
|
||||
GITHUB_REPOSITORY=crazy-max/test-docker-action
|
||||
GITHUB_REPOSITORY_OWNER=crazy-max
|
||||
GITHUB_RETENTION_DAYS=90
|
||||
GITHUB_RUN_ID=325968230
|
||||
GITHUB_RUN_NUMBER=4
|
||||
GITHUB_SERVER_URL=https://github.com
|
||||
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
|
||||
GITHUB_WORKFLOW=event
|
||||
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action
|
@@ -557,6 +557,35 @@ describe('push', () => {
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'push16',
|
||||
'event_push_defbranch.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=match,enable=false,pattern=v(.*),group=1,value=v1.2.3`,
|
||||
`type=edge`
|
||||
],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'edge',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'user/app:edge'
|
||||
],
|
||||
[
|
||||
"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=edge",
|
||||
"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);
|
||||
});
|
||||
@@ -684,7 +713,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -715,7 +744,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",group=1`
|
||||
`type=match,"pattern=^v(\\d.\\d.\\d)$",group=1`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -746,7 +775,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}-(alpha|beta).\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d-(alpha|beta).\\d+"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -777,7 +806,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -808,24 +837,29 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=/^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$/ig",group=1`,
|
||||
`type=match,"pattern=v(.*)-beta.(.*)",group=1`,
|
||||
`type=match,"pattern=v(.*)-beta.(.*)",group=2`,
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'v2.0.8-beta.67',
|
||||
partial: [],
|
||||
latest: false
|
||||
main: '2.0.8',
|
||||
partial: ['67'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:v2.0.8-beta.67',
|
||||
'ghcr.io/user/app:v2.0.8-beta.67'
|
||||
'org/app:2.0.8',
|
||||
'org/app:67',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:2.0.8',
|
||||
'ghcr.io/user/app:67',
|
||||
'ghcr.io/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=v2.0.8-beta.67",
|
||||
"org.opencontainers.image.version=2.0.8",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
@@ -837,24 +871,21 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sometag',
|
||||
main: undefined,
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sometag',
|
||||
'ghcr.io/user/app:sometag'
|
||||
],
|
||||
[],
|
||||
[
|
||||
"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=sometag",
|
||||
"org.opencontainers.image.version=",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
@@ -1001,7 +1032,7 @@ describe('tag', () => {
|
||||
tags: [
|
||||
`type=raw,priority=2000,foo`,
|
||||
`type=semver,pattern={{version}}`,
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -1060,6 +1091,125 @@ describe('tag', () => {
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag17',
|
||||
'event_tag_p1-v1.0.0.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=/^v(\\d.\\d.\\d)$/ig",group=1`,
|
||||
`type=match,pattern=\\d.\\d.\\d`,
|
||||
`type=match,pattern=\\d.\\d`,
|
||||
`type=ref,event=pr`,
|
||||
`type=sha`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0',
|
||||
partial: ['1.0', 'sha-90dd603'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-90dd603',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-90dd603',
|
||||
'ghcr.io/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=1.0.0",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag18',
|
||||
'event_tag_p1-v1.0.0.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,pattern=p1-v(\\d.\\d.\\d),group=1`,
|
||||
`type=match,pattern=p1-v(\\d.\\d),group=1`,
|
||||
`type=match,pattern=p1-v(\\d.\\d),group=3`,
|
||||
`type=ref,event=pr`,
|
||||
`type=sha`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0',
|
||||
partial: ['1.0', 'sha-90dd603'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-90dd603',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-90dd603',
|
||||
'ghcr.io/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=1.0.0",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag19',
|
||||
'event_tag_p1-v1.0.0.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,pattern=p1-v(\\d.\\d.\\d),group=1`,
|
||||
`type=match,pattern=p1-v(\\d.\\d),group=1,suffix=`,
|
||||
`type=ref,event=pr`,
|
||||
`type=sha`
|
||||
],
|
||||
flavor: [
|
||||
`suffix=-dev`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0-dev',
|
||||
partial: ['1.0', 'sha-90dd603-dev'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0-dev',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-90dd603-dev',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0-dev',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-90dd603-dev',
|
||||
'ghcr.io/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=1.0.0-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);
|
||||
});
|
||||
@@ -1160,7 +1310,7 @@ describe('latest', () => {
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -1217,7 +1367,7 @@ describe('latest', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -1469,6 +1619,72 @@ describe('pr', () => {
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr05',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr`
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-2-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-2-bal',
|
||||
'ghcr.io/user/app:pr-2-bal'
|
||||
],
|
||||
[
|
||||
"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=pr-2-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr06',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr,prefix=`
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '2-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:2-bal',
|
||||
'ghcr.io/user/app:2-bal'
|
||||
],
|
||||
[
|
||||
"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=2-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
]
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
|
||||
@@ -1649,6 +1865,39 @@ describe('schedule', () => {
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'schedule07',
|
||||
'event_schedule.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=schedule`,
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'glo-nightly-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:glo-nightly-bal',
|
||||
'ghcr.io/user/app:glo-nightly-bal'
|
||||
],
|
||||
[
|
||||
"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=glo-nightly-bal",
|
||||
"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);
|
||||
});
|
||||
|
||||
@@ -2358,40 +2607,3 @@ describe('bake', () => {
|
||||
expect(JSON.parse(fs.readFileSync(bakeFile, 'utf8'))).toEqual(exBakeDefinition);
|
||||
});
|
||||
});
|
||||
|
||||
describe('push', () => {
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
[
|
||||
'push15',
|
||||
'event_push_defbranch.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=match,pattern=v(.*),group=1,value=v1.2.3`,
|
||||
`type=edge`
|
||||
],
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.2.3',
|
||||
partial: ['edge'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'user/app:1.2.3',
|
||||
'user/app:edge',
|
||||
'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=1.2.3",
|
||||
"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);
|
||||
});
|
||||
|
@@ -13,7 +13,7 @@ describe('transform', () => {
|
||||
`type=raw,foo`,
|
||||
`type=edge`,
|
||||
`type=semver,pattern={{version}}`,
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d",group=0`
|
||||
],
|
||||
[
|
||||
{
|
||||
@@ -21,8 +21,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Schedule],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "nightly"
|
||||
}
|
||||
},
|
||||
@@ -31,8 +29,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Semver],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": ""
|
||||
}
|
||||
@@ -42,9 +38,7 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "\\d{1,3}.\\d{1,3}.\\d{1,3}",
|
||||
"pattern": "\\d.\\d.\\d",
|
||||
"group": "0",
|
||||
"value": ""
|
||||
}
|
||||
@@ -54,8 +48,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Edge],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"branch": ""
|
||||
}
|
||||
},
|
||||
@@ -64,8 +56,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Branch
|
||||
}
|
||||
},
|
||||
@@ -74,8 +64,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Tag
|
||||
}
|
||||
},
|
||||
@@ -85,7 +73,6 @@ describe('transform', () => {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "pr-",
|
||||
"suffix": "",
|
||||
"event": RefEvent.PR
|
||||
}
|
||||
},
|
||||
@@ -94,8 +81,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
@@ -104,8 +89,7 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "true",
|
||||
"prefix": "sha-",
|
||||
"suffix": ""
|
||||
"prefix": "sha-"
|
||||
}
|
||||
}
|
||||
] as Tag[],
|
||||
@@ -135,8 +119,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Schedule],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{date 'YYYYMMDD'}}"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -149,8 +131,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Semver],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": ""
|
||||
}
|
||||
@@ -164,8 +144,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": "1",
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": ""
|
||||
}
|
||||
@@ -179,8 +157,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": "1",
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": "v1.0.0"
|
||||
}
|
||||
@@ -194,8 +170,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "v(.*)",
|
||||
"group": "1",
|
||||
"value": ""
|
||||
@@ -204,15 +178,13 @@ describe('parse', () => {
|
||||
false
|
||||
],
|
||||
[
|
||||
`type=match,enable=true,"pattern=^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",group=1`,
|
||||
`type=match,enable=true,"pattern=^v(\\d.\\d.\\d)$",group=1`,
|
||||
{
|
||||
type: Type.Match,
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",
|
||||
"pattern": "^v(\\d.\\d.\\d)$",
|
||||
"group": "1",
|
||||
"value": ""
|
||||
}
|
||||
@@ -226,8 +198,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": "700",
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "v(.*)",
|
||||
"group": "1",
|
||||
"value": ""
|
||||
@@ -242,8 +212,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "v(.*)",
|
||||
"group": "1",
|
||||
"value": "v1.2.3"
|
||||
@@ -263,8 +231,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Edge],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"branch": ""
|
||||
}
|
||||
} as Tag,
|
||||
@@ -277,8 +243,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Edge],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"branch": "master"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -291,8 +255,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Tag
|
||||
}
|
||||
} as Tag,
|
||||
@@ -305,8 +267,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Branch
|
||||
}
|
||||
} as Tag,
|
||||
@@ -320,7 +280,6 @@ describe('parse', () => {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "pr-",
|
||||
"suffix": "",
|
||||
"event": RefEvent.PR
|
||||
}
|
||||
} as Tag,
|
||||
@@ -343,8 +302,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -362,8 +319,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag2"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -376,8 +331,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag4"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -390,8 +343,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "false",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag5"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -404,8 +355,7 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "true",
|
||||
"prefix": "sha-",
|
||||
"suffix": ""
|
||||
"prefix": "sha-"
|
||||
}
|
||||
} as Tag,
|
||||
false
|
||||
@@ -417,8 +367,7 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": ""
|
||||
"prefix": ""
|
||||
}
|
||||
} as Tag,
|
||||
false
|
||||
@@ -430,8 +379,7 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "false",
|
||||
"prefix": "sha-",
|
||||
"suffix": ""
|
||||
"prefix": "sha-"
|
||||
}
|
||||
} as Tag,
|
||||
false
|
||||
|
114
dist/index.js
generated
vendored
114
dist/index.js
generated
vendored
@@ -99,12 +99,32 @@ exports.asyncForEach = (array, callback) => __awaiter(void 0, void 0, void 0, fu
|
||||
/***/ }),
|
||||
|
||||
/***/ 3716:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Transform = void 0;
|
||||
const core = __importStar(__webpack_require__(2186));
|
||||
function Transform(inputs) {
|
||||
const flavor = {
|
||||
latest: 'auto',
|
||||
@@ -137,6 +157,11 @@ function Transform(inputs) {
|
||||
}
|
||||
}
|
||||
}
|
||||
core.startGroup(`Processing flavor input`);
|
||||
core.info(`latest=${flavor.latest}`);
|
||||
core.info(`prefix=${flavor.prefix}`);
|
||||
core.info(`suffix=${flavor.suffix}`);
|
||||
core.endGroup();
|
||||
return flavor;
|
||||
}
|
||||
exports.Transform = Transform;
|
||||
@@ -414,11 +439,11 @@ class Meta {
|
||||
return version;
|
||||
}
|
||||
const currentDate = this.date;
|
||||
const vraw = handlebars.compile(tag.attrs['pattern'])({
|
||||
const vraw = this.setFlavor(handlebars.compile(tag.attrs['pattern'])({
|
||||
date: function (format) {
|
||||
return moment_1.default(currentDate).utc().format(format);
|
||||
}
|
||||
});
|
||||
}), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
@@ -450,24 +475,18 @@ class Meta {
|
||||
includePrerelease: true
|
||||
});
|
||||
if (semver.prerelease(vraw)) {
|
||||
vraw = handlebars.compile('{{version}}')(sver);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
vraw = this.setFlavor(handlebars.compile('{{version}}')(sver), tag);
|
||||
}
|
||||
else {
|
||||
vraw = handlebars.compile(tag.attrs['pattern'])(sver);
|
||||
vraw = this.setFlavor(handlebars.compile(tag.attrs['pattern'])(sver), tag);
|
||||
latest = true;
|
||||
}
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
latest = true;
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
|
||||
}
|
||||
@@ -493,10 +512,16 @@ class Meta {
|
||||
else {
|
||||
tmatch = vraw.match(tag.attrs['pattern']);
|
||||
}
|
||||
if (tmatch) {
|
||||
vraw = tmatch[tag.attrs['group']];
|
||||
latest = true;
|
||||
if (!tmatch) {
|
||||
core.warning(`${tag.attrs['pattern']} does not match ${vraw}.`);
|
||||
return version;
|
||||
}
|
||||
if (typeof tmatch[tag.attrs['group']] === 'undefined') {
|
||||
core.warning(`Group ${tag.attrs['group']} does not exist for ${tag.attrs['pattern']} pattern.`);
|
||||
return version;
|
||||
}
|
||||
vraw = this.setFlavor(tmatch[tag.attrs['group']], tag);
|
||||
latest = true;
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
@@ -609,13 +634,13 @@ class Meta {
|
||||
return version;
|
||||
}
|
||||
setFlavor(val, tag) {
|
||||
if (tag.attrs['prefix'].length > 0) {
|
||||
if (tag.attrs.hasOwnProperty('prefix')) {
|
||||
val = `${tag.attrs['prefix']}${val}`;
|
||||
}
|
||||
else if (this.flavor.prefix.length > 0) {
|
||||
val = `${this.flavor.prefix}${val}`;
|
||||
}
|
||||
if (tag.attrs['suffix'].length > 0) {
|
||||
if (tag.attrs.hasOwnProperty('suffix')) {
|
||||
val = `${val}${tag.attrs['suffix']}`;
|
||||
}
|
||||
else if (this.flavor.suffix.length > 0) {
|
||||
@@ -690,12 +715,32 @@ exports.Meta = Meta;
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Parse = exports.Transform = exports.DefaultPriorities = exports.RefEvent = exports.Type = void 0;
|
||||
exports.Parse = exports.Transform = exports.DefaultPriorities = exports.Tag = exports.RefEvent = exports.Type = void 0;
|
||||
const sync_1 = __importDefault(__webpack_require__(8750));
|
||||
const core = __importStar(__webpack_require__(2186));
|
||||
var Type;
|
||||
(function (Type) {
|
||||
Type["Schedule"] = "schedule";
|
||||
@@ -712,6 +757,19 @@ var RefEvent;
|
||||
RefEvent["Tag"] = "tag";
|
||||
RefEvent["PR"] = "pr";
|
||||
})(RefEvent = exports.RefEvent || (exports.RefEvent = {}));
|
||||
class Tag {
|
||||
constructor() {
|
||||
this.attrs = {};
|
||||
}
|
||||
toString() {
|
||||
const out = [`type=${this.type}`];
|
||||
for (let attr in this.attrs) {
|
||||
out.push(`${attr}=${this.attrs[attr]}`);
|
||||
}
|
||||
return out.join(',');
|
||||
}
|
||||
}
|
||||
exports.Tag = Tag;
|
||||
exports.DefaultPriorities = {
|
||||
[Type.Schedule]: '1000',
|
||||
[Type.Semver]: '900',
|
||||
@@ -735,7 +793,7 @@ function Transform(inputs) {
|
||||
for (const input of inputs) {
|
||||
tags.push(Parse(input));
|
||||
}
|
||||
return tags.sort((tag1, tag2) => {
|
||||
const sorted = tags.sort((tag1, tag2) => {
|
||||
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
|
||||
return 1;
|
||||
}
|
||||
@@ -744,6 +802,12 @@ function Transform(inputs) {
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
core.startGroup(`Processing tags input`);
|
||||
for (const tag of sorted) {
|
||||
core.info(tag.toString());
|
||||
}
|
||||
core.endGroup();
|
||||
return sorted;
|
||||
}
|
||||
exports.Transform = Transform;
|
||||
function Parse(s) {
|
||||
@@ -751,9 +815,7 @@ function Parse(s) {
|
||||
relaxColumnCount: true,
|
||||
skipLinesWithEmptyValues: true
|
||||
})[0];
|
||||
const tag = {
|
||||
attrs: {}
|
||||
};
|
||||
const tag = new Tag();
|
||||
for (const field of fields) {
|
||||
const parts = field.toString().split('=', 2);
|
||||
if (parts.length == 1) {
|
||||
@@ -850,12 +912,6 @@ function Parse(s) {
|
||||
if (!tag.attrs.hasOwnProperty('priority')) {
|
||||
tag.attrs['priority'] = exports.DefaultPriorities[tag.type];
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('prefix')) {
|
||||
tag.attrs['prefix'] = '';
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('suffix')) {
|
||||
tag.attrs['suffix'] = '';
|
||||
}
|
||||
if (!['true', 'false'].includes(tag.attrs['enable'])) {
|
||||
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export interface Flavor {
|
||||
latest: string;
|
||||
prefix: string;
|
||||
@@ -38,5 +40,11 @@ export function Transform(inputs: string[]): Flavor {
|
||||
}
|
||||
}
|
||||
|
||||
core.startGroup(`Processing flavor input`);
|
||||
core.info(`latest=${flavor.latest}`);
|
||||
core.info(`prefix=${flavor.prefix}`);
|
||||
core.info(`suffix=${flavor.suffix}`);
|
||||
core.endGroup();
|
||||
|
||||
return flavor;
|
||||
}
|
||||
|
38
src/meta.ts
38
src/meta.ts
@@ -47,7 +47,6 @@ export class Meta {
|
||||
if (tag.attrs['enable'] == 'false') {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (tag.type) {
|
||||
case tcl.Type.Schedule: {
|
||||
version = this.procSchedule(version, tag);
|
||||
@@ -100,11 +99,14 @@ export class Meta {
|
||||
}
|
||||
|
||||
const currentDate = this.date;
|
||||
const vraw = handlebars.compile(tag.attrs['pattern'])({
|
||||
const vraw = this.setFlavor(
|
||||
handlebars.compile(tag.attrs['pattern'])({
|
||||
date: function (format) {
|
||||
return moment(currentDate).utc().format(format);
|
||||
}
|
||||
});
|
||||
}),
|
||||
tag
|
||||
);
|
||||
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
@@ -139,21 +141,16 @@ export class Meta {
|
||||
includePrerelease: true
|
||||
});
|
||||
if (semver.prerelease(vraw)) {
|
||||
vraw = handlebars.compile('{{version}}')(sver);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
vraw = this.setFlavor(handlebars.compile('{{version}}')(sver), tag);
|
||||
} else {
|
||||
vraw = handlebars.compile(tag.attrs['pattern'])(sver);
|
||||
vraw = this.setFlavor(handlebars.compile(tag.attrs['pattern'])(sver), tag);
|
||||
latest = true;
|
||||
}
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
latest = true;
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
|
||||
}
|
||||
@@ -181,10 +178,17 @@ export class Meta {
|
||||
} else {
|
||||
tmatch = vraw.match(tag.attrs['pattern']);
|
||||
}
|
||||
if (tmatch) {
|
||||
vraw = tmatch[tag.attrs['group']];
|
||||
latest = true;
|
||||
if (!tmatch) {
|
||||
core.warning(`${tag.attrs['pattern']} does not match ${vraw}.`);
|
||||
return version;
|
||||
}
|
||||
if (typeof tmatch[tag.attrs['group']] === 'undefined') {
|
||||
core.warning(`Group ${tag.attrs['group']} does not exist for ${tag.attrs['pattern']} pattern.`);
|
||||
return version;
|
||||
}
|
||||
|
||||
vraw = this.setFlavor(tmatch[tag.attrs['group']], tag);
|
||||
latest = true;
|
||||
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
@@ -311,12 +315,12 @@ export class Meta {
|
||||
}
|
||||
|
||||
private setFlavor(val: string, tag: tcl.Tag): string {
|
||||
if (tag.attrs['prefix'].length > 0) {
|
||||
if (tag.attrs.hasOwnProperty('prefix')) {
|
||||
val = `${tag.attrs['prefix']}${val}`;
|
||||
} else if (this.flavor.prefix.length > 0) {
|
||||
val = `${this.flavor.prefix}${val}`;
|
||||
}
|
||||
if (tag.attrs['suffix'].length > 0) {
|
||||
if (tag.attrs.hasOwnProperty('suffix')) {
|
||||
val = `${val}${tag.attrs['suffix']}`;
|
||||
} else if (this.flavor.suffix.length > 0) {
|
||||
val = `${val}${this.flavor.suffix}`;
|
||||
|
41
src/tag.ts
41
src/tag.ts
@@ -1,4 +1,5 @@
|
||||
import csvparse from 'csv-parse/lib/sync';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export enum Type {
|
||||
Schedule = 'schedule',
|
||||
@@ -16,9 +17,21 @@ export enum RefEvent {
|
||||
PR = 'pr'
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
type: Type;
|
||||
attrs: Record<string, string>;
|
||||
export class Tag {
|
||||
public type?: Type;
|
||||
public attrs: Record<string, string>;
|
||||
|
||||
constructor() {
|
||||
this.attrs = {};
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
const out: string[] = [`type=${this.type}`];
|
||||
for (let attr in this.attrs) {
|
||||
out.push(`${attr}=${this.attrs[attr]}`);
|
||||
}
|
||||
return out.join(',');
|
||||
}
|
||||
}
|
||||
|
||||
export const DefaultPriorities: Record<Type, string> = {
|
||||
@@ -42,10 +55,11 @@ export function Transform(inputs: string[]): Tag[] {
|
||||
`type=ref,event=${RefEvent.PR}`
|
||||
];
|
||||
}
|
||||
|
||||
for (const input of inputs) {
|
||||
tags.push(Parse(input));
|
||||
}
|
||||
return tags.sort((tag1, tag2) => {
|
||||
const sorted = tags.sort((tag1, tag2) => {
|
||||
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
|
||||
return 1;
|
||||
}
|
||||
@@ -54,6 +68,14 @@ export function Transform(inputs: string[]): Tag[] {
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
core.startGroup(`Processing tags input`);
|
||||
for (const tag of sorted) {
|
||||
core.info(tag.toString());
|
||||
}
|
||||
core.endGroup();
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
export function Parse(s: string): Tag {
|
||||
@@ -62,10 +84,7 @@ export function Parse(s: string): Tag {
|
||||
skipLinesWithEmptyValues: true
|
||||
})[0];
|
||||
|
||||
const tag = {
|
||||
attrs: {}
|
||||
} as Tag;
|
||||
|
||||
const tag = new Tag();
|
||||
for (const field of fields) {
|
||||
const parts = field.toString().split('=', 2);
|
||||
if (parts.length == 1) {
|
||||
@@ -166,12 +185,6 @@ export function Parse(s: string): Tag {
|
||||
if (!tag.attrs.hasOwnProperty('priority')) {
|
||||
tag.attrs['priority'] = DefaultPriorities[tag.type];
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('prefix')) {
|
||||
tag.attrs['prefix'] = '';
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('suffix')) {
|
||||
tag.attrs['suffix'] = '';
|
||||
}
|
||||
if (!['true', 'false'].includes(tag.attrs['enable'])) {
|
||||
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
|
||||
}
|
||||
|
Reference in New Issue
Block a user