Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
05d22bf317 | ||
|
70b403b46b | ||
|
9e6ae02878 | ||
|
3d239e8b8a | ||
|
7cb52e2750 | ||
|
90a1d5cf21 | ||
|
c98ac5e987 | ||
|
44d853bc0a | ||
|
d1abf80723 | ||
|
3358a27538 | ||
|
314ddf6d4a | ||
|
b91e8f52b0 | ||
|
fbac5f9bca | ||
|
57396166ad | ||
|
473bdc561c | ||
|
ebedea2c18 | ||
|
d00b20e38f | ||
|
a99e71cdc7 |
38
README.md
38
README.md
@@ -1,6 +1,7 @@
|
|||||||
[](https://github.com/docker/metadata-action/releases/latest)
|
[](https://github.com/docker/metadata-action/releases/latest)
|
||||||
[](https://github.com/marketplace/actions/docker-metadata-action)
|
[](https://github.com/marketplace/actions/docker-metadata-action)
|
||||||
[](https://github.com/docker/metadata-action/actions?workflow=test)
|
[](https://github.com/docker/metadata-action/actions?workflow=ci)
|
||||||
|
[](https://github.com/docker/metadata-action/actions?workflow=test)
|
||||||
[](https://codecov.io/gh/docker/metadata-action)
|
[](https://codecov.io/gh/docker/metadata-action)
|
||||||
|
|
||||||
## About
|
## About
|
||||||
@@ -20,6 +21,7 @@ ___
|
|||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
|
* [environment variables](#environment-variables)
|
||||||
* [`images` input](#images-input)
|
* [`images` input](#images-input)
|
||||||
* [`flavor` input](#flavor-input)
|
* [`flavor` input](#flavor-input)
|
||||||
* [`tags` input](#tags-input)
|
* [`tags` input](#tags-input)
|
||||||
@@ -41,7 +43,7 @@ ___
|
|||||||
* [`{{sha}}`](#sha)
|
* [`{{sha}}`](#sha)
|
||||||
* [`{{base_ref}}`](#base_ref)
|
* [`{{base_ref}}`](#base_ref)
|
||||||
* [`{{is_default_branch}}`](#is_default_branch)
|
* [`{{is_default_branch}}`](#is_default_branch)
|
||||||
* [`{{date '<format>'}}`](#date-format)
|
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
||||||
* [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)
|
||||||
@@ -295,6 +297,12 @@ Following outputs are available
|
|||||||
| `json` | String | JSON output of tags and labels |
|
| `json` | String | JSON output of tags and labels |
|
||||||
| `bake-file` | File | [Bake file definition](https://docs.docker.com/build/customize/bake/file-definition/) path |
|
| `bake-file` | File | [Bake file definition](https://docs.docker.com/build/customize/bake/file-definition/) path |
|
||||||
|
|
||||||
|
### environment variables
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
|-------------------------------|------|------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
|
||||||
|
|
||||||
## `images` input
|
## `images` input
|
||||||
|
|
||||||
`images` defines a list of Docker images to use as base name for [`tags`](#tags-input):
|
`images` defines a list of Docker images to use as base name for [`tags`](#tags-input):
|
||||||
@@ -391,6 +399,8 @@ tags: |
|
|||||||
type=schedule,pattern=nightly
|
type=schedule,pattern=nightly
|
||||||
# handlebars
|
# handlebars
|
||||||
type=schedule,pattern={{date 'YYYYMMDD'}}
|
type=schedule,pattern={{date 'YYYYMMDD'}}
|
||||||
|
# handlebars with timezone
|
||||||
|
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Will be used on [schedule event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
|
Will be used on [schedule event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
|
||||||
@@ -398,12 +408,14 @@ Will be used on [schedule event](https://docs.github.com/en/actions/using-workfl
|
|||||||
`pattern` is a specially crafted attribute to support [Handlebars' template](https://handlebarsjs.com/guide/)
|
`pattern` is a specially crafted attribute to support [Handlebars' template](https://handlebarsjs.com/guide/)
|
||||||
with the following expressions:
|
with the following expressions:
|
||||||
|
|
||||||
* `date 'format'` ; render date by its [moment format](https://momentjs.com/docs/#/displaying/format/)
|
* `date 'format' tz='Timezone'` ; render date by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
||||||
|
Default `tz` is UTC.
|
||||||
|
|
||||||
| Pattern | Output |
|
| Pattern | Output |
|
||||||
|--------------------------|----------------------|
|
|----------------------------------------------|-------------------|
|
||||||
| `nightly` | `nightly` |
|
| `nightly` | `nightly` |
|
||||||
| `{{date 'YYYYMMDD'}}` | `20210326` |
|
| `{{date 'YYYYMMDD'}}` | `20200110` |
|
||||||
|
| `{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` |
|
||||||
|
|
||||||
Extended attributes and default values:
|
Extended attributes and default values:
|
||||||
|
|
||||||
@@ -768,14 +780,16 @@ workflow run. Will be empty for a branch reference:
|
|||||||
Returns `true` if the branch that triggered the workflow run is the default
|
Returns `true` if the branch that triggered the workflow run is the default
|
||||||
one, otherwise `false`.
|
one, otherwise `false`.
|
||||||
|
|
||||||
#### `{{date '<format>'}}`
|
#### `{{date '<format>' tz='<timezone>'}}`
|
||||||
|
|
||||||
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
||||||
|
Default `tz` is UTC.
|
||||||
|
|
||||||
| Expression | Output example |
|
| Expression | Output example |
|
||||||
|--------------------------------------------|-----------------------------------------|
|
|----------------------------------------------|-----------------------------------------|
|
||||||
| `{{date 'YYYYMMDD'}}` | `20200110` |
|
| `{{date 'YYYYMMDD'}}` | `20200110` |
|
||||||
| `{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
|
| `{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
|
||||||
|
| `{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` |
|
||||||
|
|
||||||
### Major version zero
|
### Major version zero
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as dotenv from 'dotenv';
|
import * as dotenv from 'dotenv';
|
||||||
import * as moment from 'moment';
|
import moment from 'moment-timezone';
|
||||||
import {getInputs, Inputs} from '../src/context';
|
import {getInputs, Inputs} from '../src/context';
|
||||||
import * as github from '../src/github';
|
import * as github from '../src/github';
|
||||||
import {Meta, Version} from '../src/meta';
|
import {Meta, Version} from '../src/meta';
|
||||||
@@ -21,8 +21,8 @@ jest.spyOn(global.Date.prototype, 'toISOString').mockImplementation(() => {
|
|||||||
return '2020-01-10T00:30:00.000Z';
|
return '2020-01-10T00:30:00.000Z';
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mock('moment', () => {
|
jest.mock('moment-timezone', () => {
|
||||||
return () => (jest.requireActual('moment') as typeof import('moment'))('2020-01-10T00:30:00.000Z');
|
return () => (jest.requireActual('moment-timezone') as typeof import('moment-timezone'))('2020-01-10T00:30:00.000Z');
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -599,6 +599,7 @@ describe('push', () => {
|
|||||||
tags: [
|
tags: [
|
||||||
`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-{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}`,
|
||||||
`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}}`
|
`type=raw,value=mytag-defbranch,enable={{is_default_branch}}`
|
||||||
@@ -608,6 +609,7 @@ describe('push', () => {
|
|||||||
main: 'mytag-master',
|
main: 'mytag-master',
|
||||||
partial: [
|
partial: [
|
||||||
'mytag-20200110',
|
'mytag-20200110',
|
||||||
|
'mytag-20200110-093000',
|
||||||
'mytag-tag-',
|
'mytag-tag-',
|
||||||
'mytag-baseref-',
|
'mytag-baseref-',
|
||||||
'mytag-defbranch'
|
'mytag-defbranch'
|
||||||
@@ -617,6 +619,7 @@ describe('push', () => {
|
|||||||
[
|
[
|
||||||
'user/app:mytag-master',
|
'user/app:mytag-master',
|
||||||
'user/app:mytag-20200110',
|
'user/app:mytag-20200110',
|
||||||
|
'user/app:mytag-20200110-093000',
|
||||||
'user/app:mytag-tag-',
|
'user/app:mytag-tag-',
|
||||||
'user/app:mytag-baseref-',
|
'user/app:mytag-baseref-',
|
||||||
'user/app:mytag-defbranch'
|
'user/app:mytag-defbranch'
|
||||||
@@ -2067,6 +2070,354 @@ describe('latest', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('pr', () => {
|
describe('pr', () => {
|
||||||
|
// prettier-ignore
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
|
test.each([
|
||||||
|
[
|
||||||
|
'pr01',
|
||||||
|
'event_pull_request.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'pr-15',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:pr-15'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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-15",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=a9c8c5828b91be19d9728548b24759e352367ef1",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr02',
|
||||||
|
'event_pull_request.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'pr-15',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:pr-15',
|
||||||
|
'ghcr.io/user/app:pr-15'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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-15",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=a9c8c5828b91be19d9728548b24759e352367ef1",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr03',
|
||||||
|
'event_pull_request.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tags: [
|
||||||
|
`type=ref,event=pr`,
|
||||||
|
`type=sha`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'pr-15',
|
||||||
|
partial: ['sha-a9c8c58'],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:pr-15',
|
||||||
|
'org/app:sha-a9c8c58',
|
||||||
|
'ghcr.io/user/app:pr-15',
|
||||||
|
'ghcr.io/user/app:sha-a9c8c58'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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-15",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=a9c8c5828b91be19d9728548b24759e352367ef1",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr04',
|
||||||
|
'event_pull_request.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tags: [
|
||||||
|
`type=sha,priority=2000`,
|
||||||
|
`type=ref,event=pr`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'sha-a9c8c58',
|
||||||
|
partial: ['pr-15'],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:sha-a9c8c58',
|
||||||
|
'org/app:pr-15',
|
||||||
|
'ghcr.io/user/app:sha-a9c8c58',
|
||||||
|
'ghcr.io/user/app:pr-15'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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-a9c8c58",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=a9c8c5828b91be19d9728548b24759e352367ef1",
|
||||||
|
"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-15-bal',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:pr-15-bal',
|
||||||
|
'ghcr.io/user/app:pr-15-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-15-bal",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=a9c8c5828b91be19d9728548b24759e352367ef1",
|
||||||
|
"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: '15-bal',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:15-bal',
|
||||||
|
'ghcr.io/user/app:15-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=15-bal",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=a9c8c5828b91be19d9728548b24759e352367ef1",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr07',
|
||||||
|
'event_pull_request_target.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tags: [
|
||||||
|
`type=sha,priority=2000`,
|
||||||
|
`type=ref,event=pr`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'sha-2665741',
|
||||||
|
partial: ['pr-15'],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:sha-2665741',
|
||||||
|
'org/app:pr-15',
|
||||||
|
'ghcr.io/user/app:sha-2665741',
|
||||||
|
'ghcr.io/user/app:pr-15'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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-2665741",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=266574110acf203503badf966df2ea24b5d732d7",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr08',
|
||||||
|
'event_pull_request_target.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tags: [
|
||||||
|
`type=ref,event=pr,prefix=`
|
||||||
|
],
|
||||||
|
flavor: [
|
||||||
|
`prefix=glo-`,
|
||||||
|
`suffix=-bal`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '15-bal',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:15-bal',
|
||||||
|
'ghcr.io/user/app:15-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=15-bal",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=266574110acf203503badf966df2ea24b5d732d7",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr09',
|
||||||
|
'event_pull_request_target.env',
|
||||||
|
{
|
||||||
|
images: ['org/app'],
|
||||||
|
tags: [
|
||||||
|
`type=ref,event=tag`,
|
||||||
|
`type=ref,event=pr`,
|
||||||
|
`type=ref,event=branch`,
|
||||||
|
`type=sha`,
|
||||||
|
`type=sha,format=long`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'pr-15',
|
||||||
|
partial: [
|
||||||
|
'sha-2665741',
|
||||||
|
'sha-266574110acf203503badf966df2ea24b5d732d7'
|
||||||
|
],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:pr-15',
|
||||||
|
'org/app:sha-2665741',
|
||||||
|
'org/app:sha-266574110acf203503badf966df2ea24b5d732d7'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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-15",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=266574110acf203503badf966df2ea24b5d732d7",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr10',
|
||||||
|
'event_pull_request_target.env',
|
||||||
|
{
|
||||||
|
images: ['org/app'],
|
||||||
|
tags: [
|
||||||
|
`type=raw,value=mytag-{{base_ref}}`,
|
||||||
|
`type=raw,mytag-defbranch,enable={{is_default_branch}}`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'mytag-master',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:mytag-master'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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=mytag-master",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=266574110acf203503badf966df2ea24b5d732d7",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pr11',
|
||||||
|
'event_pull_request.env',
|
||||||
|
{
|
||||||
|
images: ['org/app'],
|
||||||
|
tags: [
|
||||||
|
`type=raw,value=mytag-{{base_ref}}`,
|
||||||
|
`type=raw,mytag-defbranch,enable={{is_default_branch}}`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'mytag-master',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:mytag-master'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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=mytag-master",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=a9c8c5828b91be19d9728548b24759e352367ef1",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
])('given %p with %p event', tagsLabelsTest);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('pr-head-sha', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line jest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
@@ -2411,7 +2762,23 @@ describe('pr', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabels: Array<string>) => {
|
||||||
|
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||||
|
process.env.DOCKER_METADATA_PR_HEAD_SHA = 'true';
|
||||||
|
const context = github.context();
|
||||||
|
|
||||||
|
const repo = await github.repo(process.env.GITHUB_TOKEN || '');
|
||||||
|
const meta = new Meta({...getInputs(), ...inputs}, context, repo);
|
||||||
|
|
||||||
|
const version = meta.version;
|
||||||
|
expect(version).toEqual(exVersion);
|
||||||
|
|
||||||
|
const tags = meta.getTags();
|
||||||
|
expect(tags).toEqual(exTags);
|
||||||
|
|
||||||
|
const labels = meta.getLabels();
|
||||||
|
expect(labels).toEqual(exLabels);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('schedule', () => {
|
describe('schedule', () => {
|
||||||
@@ -2631,6 +2998,34 @@ describe('schedule', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'schedule08',
|
||||||
|
'event_schedule.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
tags: [
|
||||||
|
`type=schedule,pattern={{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}`
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '20200110-093000',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:20200110-093000'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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=20200110-093000",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %p with %p event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -126,6 +126,18 @@ describe('parse', () => {
|
|||||||
} as Tag,
|
} as Tag,
|
||||||
false
|
false
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
`type=schedule,enable=true,pattern={{date 'YYYYMMDD' tz='Asia/Tokyo'}}`,
|
||||||
|
{
|
||||||
|
type: Type.Schedule,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Schedule],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": `{{date 'YYYYMMDD' tz='Asia/Tokyo'}}`
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
[
|
[
|
||||||
`type=semver,enable=true,pattern={{version}}`,
|
`type=semver,enable=true,pattern={{version}}`,
|
||||||
{
|
{
|
||||||
|
30
dist/index.js
generated
vendored
30
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
23
dist/licenses.txt
generated
vendored
23
dist/licenses.txt
generated
vendored
@@ -627,6 +627,29 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||||||
OTHER DEALINGS IN THE SOFTWARE.
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
moment-timezone
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) JS Foundation and other contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
node-fetch
|
node-fetch
|
||||||
MIT
|
MIT
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
@@ -32,9 +32,10 @@
|
|||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"@renovate/pep440": "^1.0.0",
|
"@renovate/pep440": "^1.0.0",
|
||||||
"csv-parse": "^5.3.0",
|
"csv-parse": "^5.3.3",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
|
"moment-timezone": "^0.5.40",
|
||||||
"semver": "^7.3.7"
|
"semver": "^7.3.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
41
src/meta.ts
41
src/meta.ts
@@ -1,7 +1,7 @@
|
|||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import moment from 'moment';
|
import moment from 'moment-timezone';
|
||||||
import * as pep440 from '@renovate/pep440';
|
import * as pep440 from '@renovate/pep440';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import {Inputs, tmpDir} from './context';
|
import {Inputs, tmpDir} from './context';
|
||||||
@@ -37,8 +37,13 @@ export class Meta {
|
|||||||
context.ref = `refs/pull/${context.payload.number}/merge`;
|
context.ref = `refs/pull/${context.payload.number}/merge`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((/pull_request/.test(context.eventName) || /pull_request_target/.test(context.eventName)) && context.payload?.pull_request?.head?.sha != undefined) {
|
// DOCKER_METADATA_PR_HEAD_SHA env var can be used to set associated head
|
||||||
context.sha = context.payload.pull_request.head.sha;
|
// SHA instead of commit SHA that triggered the workflow on pull request
|
||||||
|
// event.
|
||||||
|
if (/true/i.test(process.env.DOCKER_METADATA_PR_HEAD_SHA || '')) {
|
||||||
|
if ((/pull_request/.test(context.eventName) || /pull_request_target/.test(context.eventName)) && context.payload?.pull_request?.head?.sha != undefined) {
|
||||||
|
context.sha = context.payload.pull_request.head.sha;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
@@ -124,8 +129,19 @@ export class Meta {
|
|||||||
const currentDate = this.date;
|
const currentDate = this.date;
|
||||||
const vraw = this.setValue(
|
const vraw = this.setValue(
|
||||||
handlebars.compile(tag.attrs['pattern'])({
|
handlebars.compile(tag.attrs['pattern'])({
|
||||||
date: function (format) {
|
date: function (format, options) {
|
||||||
return moment(currentDate).utc().format(format);
|
const m = moment(currentDate);
|
||||||
|
let tz = 'UTC';
|
||||||
|
Object.keys(options.hash).forEach(key => {
|
||||||
|
switch (key) {
|
||||||
|
case 'tz':
|
||||||
|
tz = options.hash[key];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown ${key} attribute`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return m.tz(tz).format(format);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
tag
|
tag
|
||||||
@@ -406,8 +422,19 @@ export class Meta {
|
|||||||
}
|
}
|
||||||
return 'false';
|
return 'false';
|
||||||
},
|
},
|
||||||
date: function (format) {
|
date: function (format, options) {
|
||||||
return moment(currentDate).utc().format(format);
|
const m = moment(currentDate);
|
||||||
|
let tz = 'UTC';
|
||||||
|
Object.keys(options.hash).forEach(key => {
|
||||||
|
switch (key) {
|
||||||
|
case 'tz':
|
||||||
|
tz = options.hash[key];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown ${key} attribute`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return m.tz(tz).format(format);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -95,7 +95,7 @@ export function Parse(s: string): Tag {
|
|||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
const parts = field
|
const parts = field
|
||||||
.toString()
|
.toString()
|
||||||
.split('=')
|
.split(/(?<=^[^=]+?)=/)
|
||||||
.map(item => item.trim());
|
.map(item => item.trim());
|
||||||
if (parts.length == 1) {
|
if (parts.length == 1) {
|
||||||
tag.attrs['value'] = parts[0];
|
tag.attrs['value'] = parts[0];
|
||||||
|
33
yarn.lock
33
yarn.lock
@@ -1560,7 +1560,7 @@ combined-stream@^1.0.8:
|
|||||||
concat-map@0.0.1:
|
concat-map@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
|
||||||
|
|
||||||
convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
|
convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
|
||||||
version "1.8.0"
|
version "1.8.0"
|
||||||
@@ -1605,10 +1605,10 @@ cssstyle@^2.3.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
cssom "~0.3.6"
|
cssom "~0.3.6"
|
||||||
|
|
||||||
csv-parse@*, csv-parse@^5.3.0:
|
csv-parse@*, csv-parse@^5.3.3:
|
||||||
version "5.3.0"
|
version "5.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.3.0.tgz#85cc02fc9d1c89bd1b02e69069c960f8b8064322"
|
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.3.3.tgz#3b75d2279e2edb550cbc54c65b25cbbf3d0033ad"
|
||||||
integrity sha512-UXJCGwvJ2fep39purtAn27OUYmxB1JQto+zhZ4QlJpzsirtSFbzLvip1aIgziqNdZp/TptvsKEV5BZSxe10/DQ==
|
integrity sha512-kEWkAPleNEdhFNkHQpFHu9RYPogsFj3dx6bCxL847fsiLgidzWg0z/O0B1kVWMJUc5ky64zGp18LX2T3DQrOfw==
|
||||||
|
|
||||||
data-urls@^2.0.0:
|
data-urls@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
@@ -2822,11 +2822,9 @@ json-stable-stringify-without-jsonify@^1.0.1:
|
|||||||
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
|
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
|
||||||
|
|
||||||
json5@2.x, json5@^2.1.2:
|
json5@2.x, json5@^2.1.2:
|
||||||
version "2.2.0"
|
version "2.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3"
|
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
|
||||||
integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==
|
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
|
||||||
dependencies:
|
|
||||||
minimist "^1.2.5"
|
|
||||||
|
|
||||||
kleur@^3.0.3:
|
kleur@^3.0.3:
|
||||||
version "3.0.3"
|
version "3.0.3"
|
||||||
@@ -2943,9 +2941,9 @@ mimic-fn@^2.1.0:
|
|||||||
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
|
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
|
||||||
|
|
||||||
minimatch@^3.0.4:
|
minimatch@^3.0.4:
|
||||||
version "3.0.4"
|
version "3.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
|
||||||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion "^1.1.7"
|
brace-expansion "^1.1.7"
|
||||||
|
|
||||||
@@ -2954,7 +2952,14 @@ minimist@^1.2.5:
|
|||||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||||
|
|
||||||
moment@^2.29.4:
|
moment-timezone@^0.5.40:
|
||||||
|
version "0.5.40"
|
||||||
|
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.40.tgz#c148f5149fd91dd3e29bf481abc8830ecba16b89"
|
||||||
|
integrity sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg==
|
||||||
|
dependencies:
|
||||||
|
moment ">= 2.9.0"
|
||||||
|
|
||||||
|
"moment@>= 2.9.0", moment@^2.29.4:
|
||||||
version "2.29.4"
|
version "2.29.4"
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
|
||||||
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
|
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
|
||||||
|
Reference in New Issue
Block a user