mirror of
https://github.com/docker/metadata-action.git
synced 2025-12-14 21:39:07 +08:00
Merge pull request #489 from crazy-max/labels-template
Some checks failed
test / test (push) Failing after 15s
validate / prepare (push) Failing after 15s
validate / validate (push) Has been skipped
ci / context (git) (push) Successful in 5s
ci / context (workflow) (push) Successful in 5s
ci / multi-images (push) Failing after 6s
ci / tag-schedule () (push) Failing after 5s
ci / tag-schedule (schedule) (push) Failing after 6s
ci / tag-schedule ({{date 'YYYYMMDD-HHmmss'}}) (push) Failing after 6s
ci / tag-schedule (cron-{{date 'YYYYMMDD'}}) (push) Successful in 7s
ci / tag-match (\d.\d.\d, 0) (push) Failing after 5s
ci / tag-match (v(.*), 1) (push) Failing after 6s
ci / tag-match (\d.\d, 0) (push) Successful in 7s
ci / tag-semver (auto) (push) Failing after 5s
ci / tag-semver (false) (push) Failing after 6s
ci / tag-semver (true) (push) Successful in 7s
ci / flavor (push) Failing after 5s
ci / images (push) Failing after 6s
ci / global-exps (push) Failing after 5s
ci / custom-labels-annotations (push) Successful in 7s
ci / json (push) Failing after 5s
ci / bake (push) Failing after 3s
ci / sep-tags ( ) (push) Failing after 4s
ci / sep-tags (,) (push) Failing after 3s
ci / bake-annotations (push) Failing after 3s
ci / bake-cwd (push) Failing after 3s
ci / no-images (push) Failing after 5s
ci / sha-short () (push) Failing after 5s
ci / sha-short (16) (push) Failing after 5s
ci / dump (push) Failing after 3s
ci / output-env (push) Successful in 22s
ci / docker-push (push) Failing after 44s
Some checks failed
test / test (push) Failing after 15s
validate / prepare (push) Failing after 15s
validate / validate (push) Has been skipped
ci / context (git) (push) Successful in 5s
ci / context (workflow) (push) Successful in 5s
ci / multi-images (push) Failing after 6s
ci / tag-schedule () (push) Failing after 5s
ci / tag-schedule (schedule) (push) Failing after 6s
ci / tag-schedule ({{date 'YYYYMMDD-HHmmss'}}) (push) Failing after 6s
ci / tag-schedule (cron-{{date 'YYYYMMDD'}}) (push) Successful in 7s
ci / tag-match (\d.\d.\d, 0) (push) Failing after 5s
ci / tag-match (v(.*), 1) (push) Failing after 6s
ci / tag-match (\d.\d, 0) (push) Successful in 7s
ci / tag-semver (auto) (push) Failing after 5s
ci / tag-semver (false) (push) Failing after 6s
ci / tag-semver (true) (push) Successful in 7s
ci / flavor (push) Failing after 5s
ci / images (push) Failing after 6s
ci / global-exps (push) Failing after 5s
ci / custom-labels-annotations (push) Successful in 7s
ci / json (push) Failing after 5s
ci / bake (push) Failing after 3s
ci / sep-tags ( ) (push) Failing after 4s
ci / sep-tags (,) (push) Failing after 3s
ci / bake-annotations (push) Failing after 3s
ci / bake-cwd (push) Failing after 3s
ci / no-images (push) Failing after 5s
ci / sha-short () (push) Failing after 5s
ci / sha-short (16) (push) Failing after 5s
ci / dump (push) Failing after 3s
ci / output-env (push) Successful in 22s
ci / docker-push (push) Failing after 44s
global expressions support for labels and annotations
This commit is contained in:
commit
906ecf0fc0
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -269,6 +269,8 @@ jobs:
|
||||
images: |
|
||||
${{ env.DOCKER_IMAGE }}
|
||||
ghcr.io/name/app
|
||||
labels: |
|
||||
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
|
||||
tags: |
|
||||
type=sha
|
||||
type=raw,value=gexp-branch-{{branch}}
|
||||
|
||||
10
README.md
10
README.md
@ -818,7 +818,8 @@ Each tags `type` attribute has a default priority:
|
||||
### Global expressions
|
||||
|
||||
The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions
|
||||
for `prefix`, `suffix`, `value` and `enable` attributes are available:
|
||||
for `prefix`, `suffix`, `value` and `enable` attributes of `tags` input are
|
||||
available:
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
@ -828,6 +829,13 @@ tags: |
|
||||
type=raw,value=mytag-{{branch}}-{{sha}}
|
||||
```
|
||||
|
||||
They can also be applied to `labels` and `annotations` inputs:
|
||||
|
||||
```yaml
|
||||
labels: |
|
||||
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
|
||||
```
|
||||
|
||||
#### `{{branch}}`
|
||||
|
||||
Returns the branch name that triggered the workflow run. Will be empty if not
|
||||
|
||||
@ -785,6 +785,9 @@ describe('push', () => {
|
||||
`type=raw,value=mytag-baseref-{{base_ref}}`,
|
||||
`type=raw,value=mytag-defbranch,enable={{is_default_branch}}`
|
||||
],
|
||||
labels: [
|
||||
"org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}"
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'mytag-master',
|
||||
|
||||
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
@ -372,7 +372,7 @@ export class Meta {
|
||||
return val;
|
||||
}
|
||||
|
||||
private setGlobalExp(val): string {
|
||||
private setGlobalExp(val: string): string {
|
||||
const context = this.context;
|
||||
const currentDate = this.date;
|
||||
const commitDate = this.context.commitDate;
|
||||
@ -517,7 +517,9 @@ export class Meta {
|
||||
`org.opencontainers.image.revision=${this.context.sha || ''}`,
|
||||
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
|
||||
];
|
||||
res.push(...extra);
|
||||
extra.forEach(label => {
|
||||
res.push(this.setGlobalExp(label));
|
||||
});
|
||||
|
||||
return Array.from(
|
||||
new Map<string, string>(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user