Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
57396166ad | ||
|
473bdc561c | ||
|
ebedea2c18 | ||
|
d00b20e38f | ||
|
a99e71cdc7 |
@@ -20,6 +20,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)
|
||||||
@@ -295,6 +296,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):
|
||||||
|
@@ -2067,6 +2067,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 +2759,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', () => {
|
||||||
|
2
dist/index.js
generated
vendored
2
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
@@ -32,7 +32,7 @@
|
|||||||
"@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.1",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"semver": "^7.3.7"
|
"semver": "^7.3.7"
|
||||||
|
@@ -37,9 +37,14 @@ export class Meta {
|
|||||||
context.ref = `refs/pull/${context.payload.number}/merge`;
|
context.ref = `refs/pull/${context.payload.number}/merge`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DOCKER_METADATA_PR_HEAD_SHA env var can be used to set associated head
|
||||||
|
// 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) {
|
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;
|
context.sha = context.payload.pull_request.head.sha;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@@ -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.1:
|
||||||
version "5.3.0"
|
version "5.3.1"
|
||||||
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.1.tgz#78b028eb2d2a3e16e62ee8abe710ff7a0b1f8b3b"
|
||||||
integrity sha512-UXJCGwvJ2fep39purtAn27OUYmxB1JQto+zhZ4QlJpzsirtSFbzLvip1aIgziqNdZp/TptvsKEV5BZSxe10/DQ==
|
integrity sha512-R4Hv6eGJNzgcKdThZ6XORbSQ873HVcNke74QIq+LbwpT90LaZ8Xzl7KKiuIP16xq/P7ofzRt0h7S0xm+fVScsw==
|
||||||
|
|
||||||
data-urls@^2.0.0:
|
data-urls@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
|
Reference in New Issue
Block a user