diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30903d4..f9a42a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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}} diff --git a/README.md b/README.md index 9133b16..2b7cfa5 100644 --- a/README.md +++ b/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 diff --git a/__tests__/meta.test.ts b/__tests__/meta.test.ts index a75321a..45d8397 100644 --- a/__tests__/meta.test.ts +++ b/__tests__/meta.test.ts @@ -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', diff --git a/src/meta.ts b/src/meta.ts index 06bf09f..1f27746 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -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(