Compare commits

..

147 Commits

Author SHA1 Message Date
CrazyMax
f19c3691d5 Merge pull request #358 from crazy-max/empty-images
feat: allow images input to be empty to output bare tags
2023-11-30 02:04:19 -08:00
CrazyMax
4066f0cede chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-30 10:41:57 +01:00
CrazyMax
d6a296c454 chore: use anonymous func to generate tags and add tests
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-30 10:41:18 +01:00
Jason D'Amour
aacea38e07 feat: allow the images input to be empty, to output just tags
Signed-off-by: Jason D'Amour <jasondamour98@gmail.com>
2023-11-30 10:23:11 +01:00
CrazyMax
051f7ea71b Merge pull request #357 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.14.0
chore(deps): Bump @docker/actions-toolkit from 0.13.0 to 0.14.0
2023-11-30 01:21:11 -08:00
CrazyMax
2fc083a3a4 chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-30 10:15:31 +01:00
dependabot[bot]
488568d6fa chore(deps): Bump @docker/actions-toolkit from 0.13.0 to 0.14.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.13.0 to 0.14.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-30 09:13:28 +00:00
CrazyMax
f33ad1e20d Merge pull request #352 from crazy-max/annotations-alt
annotations support
2023-11-30 01:10:44 -08:00
CrazyMax
6bbe00c7bc chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-30 10:08:54 +01:00
CrazyMax
f0ad8701de annotations support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-30 10:08:54 +01:00
CrazyMax
2a4836ac76 Merge pull request #353 from crazy-max/split-bake-file
bake: split definition into two files
2023-11-27 00:50:21 -08:00
CrazyMax
9bdb15d11e chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-23 17:08:07 +01:00
CrazyMax
b94479639a bake: split definition into two files
Allows to either include tags or labels or both definitions.
Keep bake-file output for backward compatibility.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-23 17:08:07 +01:00
CrazyMax
f3c3cad8ad Merge pull request #356 from docker/dependabot/github_actions/actions/github-script-7
chore(deps): Bump actions/github-script from 6 to 7
2023-11-17 05:02:30 -08:00
dependabot[bot]
3b632771f9 chore(deps): Bump actions/github-script from 6 to 7
Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-13 19:28:14 +00:00
CrazyMax
62339db73c Merge pull request #346 from docker/dependabot/npm_and_yarn/csv-parse-5.5.2
chore(deps): Bump csv-parse from 5.5.0 to 5.5.2
2023-10-25 06:44:47 -07:00
CrazyMax
f13510ee59 fix yarn.lock
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-10-25 15:43:28 +02:00
dependabot[bot]
6796a85d36 chore(deps): Bump csv-parse from 5.5.0 to 5.5.2
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.5.0 to 5.5.2.
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.5.2/packages/csv-parse)

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-25 15:41:52 +02:00
CrazyMax
1ec392100e Merge pull request #348 from docker/dependabot/npm_and_yarn/actions/github-6.0.0
chore(deps): Bump @actions/github from 5.1.1 to 6.0.0
2023-10-25 06:41:31 -07:00
CrazyMax
15f2689f92 chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-10-25 15:39:40 +02:00
dependabot[bot]
ad9adab519 chore(deps): Bump @actions/github from 5.1.1 to 6.0.0
Bumps [@actions/github](https://github.com/actions/toolkit/tree/HEAD/packages/github) from 5.1.1 to 6.0.0.
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/github/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/github)

---
updated-dependencies:
- dependency-name: "@actions/github"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-25 13:37:52 +00:00
CrazyMax
28aeae210e Merge pull request #349 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.13.0
chore(deps): Bump @docker/actions-toolkit from 0.12.0 to 0.13.0
2023-10-25 06:36:59 -07:00
CrazyMax
5f160a25bd chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-10-25 15:15:43 +02:00
CrazyMax
05d3089a30 Merge pull request #350 from docker/dependabot/npm_and_yarn/babel/traverse-7.23.2
chore(deps): Bump @babel/traverse from 7.17.3 to 7.23.2
2023-10-25 06:13:07 -07:00
dependabot[bot]
b8c52fa5a7 chore(deps): Bump @babel/traverse from 7.17.3 to 7.23.2
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.17.3 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-17 20:40:16 +00:00
dependabot[bot]
fa851f2008 chore(deps): Bump @docker/actions-toolkit from 0.12.0 to 0.13.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.12.0...v0.13.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-13 19:33:25 +00:00
CrazyMax
879dcbb708 Merge pull request #335 from docker/dependabot/npm_and_yarn/semver-7.5.4
chore(deps): Bump semver from 7.5.3 to 7.5.4
2023-09-15 13:47:51 +02:00
CrazyMax
167d566053 chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-15 13:45:49 +02:00
CrazyMax
6dfb6f1404 Merge pull request #341 from crazy-max/community-files
chore: github form templates
2023-09-13 11:42:14 +02:00
CrazyMax
62a438bd07 chore: github form templates
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-13 09:45:28 +02:00
CrazyMax
ee5ff41fc8 chore: update community files
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-13 09:45:23 +02:00
CrazyMax
c0f15f0bfe Merge pull request #339 from docker/dependabot/github_actions/docker/setup-buildx-action-3
chore(deps): Bump docker/setup-buildx-action from 2 to 3
2023-09-13 08:31:36 +02:00
CrazyMax
2c2bddef07 Merge pull request #338 from docker/dependabot/github_actions/docker/setup-qemu-action-3
chore(deps): Bump docker/setup-qemu-action from 2 to 3
2023-09-13 08:31:23 +02:00
CrazyMax
00dcdd5da5 Merge pull request #337 from docker/dependabot/github_actions/docker/bake-action-4
chore(deps): Bump docker/bake-action from 3 to 4
2023-09-13 08:31:13 +02:00
CrazyMax
bd87541fe8 Merge pull request #336 from docker/dependabot/github_actions/docker/build-push-action-5
chore(deps): Bump docker/build-push-action from 4 to 5
2023-09-13 08:31:02 +02:00
dependabot[bot]
b87668a573 chore(deps): Bump docker/setup-buildx-action from 2 to 3
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 19:54:57 +00:00
dependabot[bot]
407b95c632 chore(deps): Bump docker/setup-qemu-action from 2 to 3
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 19:54:55 +00:00
dependabot[bot]
0668f8e3c4 chore(deps): Bump docker/bake-action from 3 to 4
Bumps [docker/bake-action](https://github.com/docker/bake-action) from 3 to 4.
- [Release notes](https://github.com/docker/bake-action/releases)
- [Commits](https://github.com/docker/bake-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/bake-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 19:54:51 +00:00
dependabot[bot]
d0efd7f63f chore(deps): Bump docker/build-push-action from 4 to 5
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 19:54:48 +00:00
dependabot[bot]
672cd7b637 chore(deps): Bump semver from 7.5.3 to 7.5.4
Bumps [semver](https://github.com/npm/node-semver) from 7.5.3 to 7.5.4.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.5.3...v7.5.4)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 19:03:27 +00:00
CrazyMax
1f35ebc704 Merge pull request #334 from crazy-max/bump-major
docs: bump actions to latest major
2023-09-12 15:14:56 +02:00
CrazyMax
413e9a9a6a docs: bump actions to latest major
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-12 14:17:25 +02:00
CrazyMax
96383f4557 Merge pull request #320 from docker/dependabot/npm_and_yarn/csv-parse-5.5.0
Bump csv-parse from 5.4.0 to 5.5.0
2023-09-12 09:35:54 +02:00
CrazyMax
f138b9677b chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-12 09:34:10 +02:00
dependabot[bot]
9cf7015b15 Bump csv-parse from 5.4.0 to 5.5.0
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.4.0 to 5.5.0.
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.5.0/packages/csv-parse)

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 07:32:56 +00:00
CrazyMax
5a8a5ff8df Merge pull request #315 from docker/dependabot/npm_and_yarn/handlebars-4.7.8
Bump handlebars from 4.7.7 to 4.7.8
2023-09-12 09:31:05 +02:00
CrazyMax
2279d9af58 chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-12 09:29:13 +02:00
dependabot[bot]
c659933213 Bump handlebars from 4.7.7 to 4.7.8
Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.7 to 4.7.8.
- [Release notes](https://github.com/handlebars-lang/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.8/release-notes.md)
- [Commits](https://github.com/handlebars-lang/handlebars.js/compare/v4.7.7...v4.7.8)

---
updated-dependencies:
- dependency-name: handlebars
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 07:24:46 +00:00
CrazyMax
48d23ccc05 Merge pull request #333 from docker/dependabot/npm_and_yarn/actions/core-1.10.1
Bump @actions/core from 1.10.0 to 1.10.1
2023-09-12 09:17:01 +02:00
CrazyMax
b83ffb48d6 chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-12 09:12:10 +02:00
dependabot[bot]
3207f2405f Bump @actions/core from 1.10.0 to 1.10.1
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.10.0 to 1.10.1.
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-12 07:00:46 +00:00
CrazyMax
63f4a263e5 Merge pull request #328 from crazy-max/update-node20
chore: node 20 as default runtime
2023-09-12 08:23:31 +02:00
CrazyMax
547dcd6d67 chore: node 20 as default runtime
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-09 18:19:59 +02:00
CrazyMax
450eef4207 chore: update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-09 18:19:58 +02:00
CrazyMax
903f5af663 chore: fix author in package.json
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-09 18:19:58 +02:00
CrazyMax
3634bd57d7 vendor: bump @docker/actions-toolkit from 0.6.0 to 0.12.0
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-09 18:19:58 +02:00
CrazyMax
d3faf0d1af chore: update dev dependencies
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-09 18:19:58 +02:00
CrazyMax
ff376f4737 chore: update to node 20
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-09 18:19:58 +02:00
CrazyMax
79f06a31c0 Merge pull request #330 from frison/master
Update Bake file-reference URI
2023-09-08 11:28:34 +02:00
Tim Frison
6f69513dab Update Bake file-reference URI
Previous URL 404'd

Signed-off-by: Tim Frison <tim.frison@clio.com>
2023-09-07 16:03:19 -06:00
CrazyMax
b67fef219a Merge pull request #324 from crazy-max/ci-concurrency
ci: missing concurrency checks
2023-09-05 11:09:54 +02:00
CrazyMax
51990f24d1 ci: missing concurrency checks
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-05 11:02:47 +02:00
CrazyMax
4af6ba2231 Merge pull request #322 from docker/dependabot/github_actions/actions/checkout-4
Bump actions/checkout from 3 to 4
2023-09-05 09:21:23 +02:00
dependabot[bot]
59de4866c5 Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 19:14:07 +00:00
CrazyMax
0f8c876baf Merge pull request #317 from crazy-max/rm-codeowners
chore: remove CODEOWNERS
2023-08-08 12:55:36 +02:00
CrazyMax
389ff6bdd5 chore: remove CODEOWNERS
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-08 12:52:23 +02:00
Tõnis Tiigi
2bcfca25d5 Merge pull request #316 from crazy-max/dependabot-update
chore: set increase as versioning strategy
2023-08-08 09:54:38 +03:00
CrazyMax
05b244eb76 chore: set increase as versioning strategy
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-08 06:01:53 +02:00
CrazyMax
35e9aff4f5 Merge pull request #306 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.6.0
Bump @docker/actions-toolkit from 0.5.0 to 0.6.0
2023-07-06 09:46:22 +02:00
CrazyMax
1586898b63 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-07-05 12:37:27 +02:00
dependabot[bot]
7a273586e1 Bump @docker/actions-toolkit from 0.5.0 to 0.6.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-28 19:30:46 +00:00
CrazyMax
ef25336f42 Merge pull request #304 from docker/dependabot/npm_and_yarn/semver-7.5.2
Bump semver from 7.5.1 to 7.5.2
2023-06-26 15:15:32 +02:00
CrazyMax
0ab15faee8 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-06-26 15:13:35 +02:00
dependabot[bot]
1ea1b02f9b Bump semver from 7.5.1 to 7.5.2
Bumps [semver](https://github.com/npm/node-semver) from 7.5.1 to 7.5.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.5.1...v7.5.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-25 12:32:27 +00:00
CrazyMax
818d4b7b91 Merge pull request #302 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.5.0
Bump @docker/actions-toolkit from 0.3.0 to 0.5.0
2023-06-13 12:27:30 +02:00
CrazyMax
948134af5e update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-06-13 12:24:59 +02:00
CrazyMax
ef7eee951a enable comments to avoid breaking change with current impl
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-06-13 12:24:00 +02:00
dependabot[bot]
8ec80c3be6 Bump @docker/actions-toolkit from 0.3.0 to 0.5.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.3.0 to 0.5.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.3.0...v0.5.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 10:11:07 +00:00
CrazyMax
38650bbf6b Merge pull request #301 from crazy-max/dedup-labels
dedup and sort labels
2023-06-13 12:02:17 +02:00
CrazyMax
ebbd9b4df7 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-06-13 02:32:15 +02:00
CrazyMax
2dadb92b6b dedup and sort labels
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-06-13 02:31:02 +02:00
CrazyMax
2c0bd771b4 Merge pull request #296 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.3.0
Bump @docker/actions-toolkit from 0.1.0 to 0.3.0
2023-06-07 15:56:56 +02:00
CrazyMax
b10b364e15 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-06-07 15:52:25 +02:00
dependabot[bot]
40a1c6ff52 Bump @docker/actions-toolkit from 0.1.0 to 0.3.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.1.0 to 0.3.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.1.0...v0.3.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-07 13:50:58 +00:00
CrazyMax
be8ea87c5a Merge pull request #294 from docker/dependabot/npm_and_yarn/csv-parse-5.4.0
Bump csv-parse from 5.3.8 to 5.4.0
2023-06-07 15:49:57 +02:00
CrazyMax
dbbf01822b Merge pull request #287 from docker/dependabot/github_actions/docker/bake-action-3
Bump docker/bake-action from 2 to 3
2023-06-02 14:54:17 +02:00
dependabot[bot]
72b4ec2b60 Bump csv-parse from 5.3.8 to 5.4.0
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.3.8 to 5.4.0.
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.4.0/packages/csv-parse)

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-26 19:57:59 +00:00
dependabot[bot]
00e2c9d34e Bump docker/bake-action from 2 to 3
Bumps [docker/bake-action](https://github.com/docker/bake-action) from 2 to 3.
- [Release notes](https://github.com/docker/bake-action/releases)
- [Commits](https://github.com/docker/bake-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/bake-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 19:57:31 +00:00
CrazyMax
c4ee3adeed Merge pull request #285 from docker/dependabot/npm_and_yarn/semver-7.5.0
Bump semver from 7.4.0 to 7.5.0
2023-04-18 09:25:43 +02:00
CrazyMax
3bea1eeada update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-04-18 09:24:34 +02:00
dependabot[bot]
88c7f0d3f6 Bump semver from 7.4.0 to 7.5.0
Bumps [semver](https://github.com/npm/node-semver) from 7.4.0 to 7.5.0.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.4.0...v7.5.0)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 07:22:30 +00:00
CrazyMax
101f9cbeaf Merge pull request #286 from docker/dependabot/npm_and_yarn/csv-parse-5.3.8
Bump csv-parse from 5.3.6 to 5.3.8
2023-04-18 09:21:45 +02:00
dependabot[bot]
0e44559303 Bump csv-parse from 5.3.6 to 5.3.8
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.3.6 to 5.3.8.
- [Release notes](https://github.com/adaltas/node-csv/releases)
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.3.8/packages/csv-parse)

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-17 19:57:54 +00:00
CrazyMax
517f8b0c3b Merge pull request #281 from docker/dependabot/npm_and_yarn/moment-timezone-0.5.43
Bump moment-timezone from 0.5.42 to 0.5.43
2023-04-17 06:36:44 +02:00
CrazyMax
bfaa9197f7 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-04-17 06:35:13 +02:00
dependabot[bot]
16dbdc96f6 Bump moment-timezone from 0.5.42 to 0.5.43
Bumps [moment-timezone](https://github.com/moment/moment-timezone) from 0.5.42 to 0.5.43.
- [Release notes](https://github.com/moment/moment-timezone/releases)
- [Changelog](https://github.com/moment/moment-timezone/blob/develop/changelog.md)
- [Commits](https://github.com/moment/moment-timezone/compare/0.5.42...0.5.43)

---
updated-dependencies:
- dependency-name: moment-timezone
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-17 04:32:40 +00:00
CrazyMax
bf095b87d3 Merge pull request #284 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.1.0
Bump @docker/actions-toolkit from 0.1.0-beta.19 to 0.1.0
2023-04-17 06:31:29 +02:00
CrazyMax
2ed3c45f27 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-04-17 04:43:59 +02:00
CrazyMax
5076359ba6 fix tests implementation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-04-17 04:43:58 +02:00
CrazyMax
d8f57c18fa update dev dependencies
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-04-17 04:36:33 +02:00
CrazyMax
80530e08c5 use new implementation from toolkit
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-04-17 04:33:51 +02:00
dependabot[bot]
da933fb889 Bump @docker/actions-toolkit from 0.1.0-beta.19 to 0.1.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.1.0-beta.19 to 0.1.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.1.0-beta.19...v0.1.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-11 19:57:48 +00:00
CrazyMax
3f6690a76c Merge pull request #278 from docker/dependabot/npm_and_yarn/moment-timezone-0.5.42
Bump moment-timezone from 0.5.41 to 0.5.42
2023-03-30 13:17:59 +02:00
CrazyMax
dda839d15b update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-03-30 13:14:41 +02:00
dependabot[bot]
37f1d84442 Bump moment-timezone from 0.5.41 to 0.5.42
Bumps [moment-timezone](https://github.com/moment/moment-timezone) from 0.5.41 to 0.5.42.
- [Release notes](https://github.com/moment/moment-timezone/releases)
- [Changelog](https://github.com/moment/moment-timezone/blob/develop/changelog.md)
- [Commits](https://github.com/moment/moment-timezone/compare/0.5.41...0.5.42)

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>

---
updated-dependencies:
- dependency-name: moment-timezone
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-30 13:13:45 +02:00
CrazyMax
1ce942256d Merge pull request #248 from escemi-tech/add-option-to-choose-between-git-or-workflow-context
allows to specify context to fetch git data
2023-03-30 12:58:07 +02:00
Emilien Escalle
8f8c795666 feat: allows to specify context to fetch git data
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
2023-03-30 12:53:58 +02:00
CrazyMax
9ec57ed1fc Merge pull request #274 from crazy-max/update-workflows
ci: split validate and test workflow
2023-03-15 15:20:07 +00:00
CrazyMax
2bdac1078b Merge pull request #268 from docker/dependabot/npm_and_yarn/moment-timezone-0.5.41
Bump moment-timezone from 0.5.40 to 0.5.41
2023-03-12 12:14:59 +00:00
CrazyMax
9e02960866 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-03-12 12:59:28 +01:00
dependabot[bot]
ea910e3ad4 Bump moment-timezone from 0.5.40 to 0.5.41
Bumps [moment-timezone](https://github.com/moment/moment-timezone) from 0.5.40 to 0.5.41.
- [Release notes](https://github.com/moment/moment-timezone/releases)
- [Changelog](https://github.com/moment/moment-timezone/blob/develop/changelog.md)
- [Commits](https://github.com/moment/moment-timezone/compare/0.5.40...0.5.41)

---
updated-dependencies:
- dependency-name: moment-timezone
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-12 11:54:47 +00:00
CrazyMax
8b6629002b Merge pull request #271 from docker/dependabot/npm_and_yarn/csv-parse-5.3.6
Bump csv-parse from 5.3.3 to 5.3.6
2023-03-12 11:53:52 +00:00
dependabot[bot]
1db8e21e35 Bump csv-parse from 5.3.3 to 5.3.6
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.3.3 to 5.3.6.
- [Release notes](https://github.com/adaltas/node-csv/releases)
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.3.6/packages/csv-parse)

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-12 11:48:00 +00:00
CrazyMax
b30cff8c11 Merge pull request #273 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.1.0-beta.19
Bump @docker/actions-toolkit from 0.1.0-beta.14 to 0.1.0-beta.19
2023-03-12 11:47:04 +00:00
CrazyMax
916b4b90e3 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-03-12 12:41:51 +01:00
CrazyMax
0ef9f130fa ci: split validate and test workflow
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-03-12 12:36:59 +01:00
dependabot[bot]
f5c49ece12 Bump @docker/actions-toolkit from 0.1.0-beta.14 to 0.1.0-beta.19
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.1.0-beta.14 to 0.1.0-beta.19.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.1.0-beta.14...v0.1.0-beta.19)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-12 11:33:46 +00:00
CrazyMax
18df8a69c4 Merge pull request #265 from docker/dependabot/github_actions/crazy-max/ghaction-dump-context-2
Bump crazy-max/ghaction-dump-context from 1 to 2
2023-03-12 11:32:38 +00:00
CrazyMax
3343011071 Merge pull request #266 from crazy-max/switch-toolkit
switch to actions-toolkit implementation
2023-02-24 19:14:13 +01:00
CrazyMax
0524f79273 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-02-21 09:23:54 +01:00
CrazyMax
b5c378621c switch to actions-toolkit implementation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-02-21 09:22:45 +01:00
dependabot[bot]
a103499e09 Bump crazy-max/ghaction-dump-context from 1 to 2
Bumps [crazy-max/ghaction-dump-context](https://github.com/crazy-max/ghaction-dump-context) from 1 to 2.
- [Release notes](https://github.com/crazy-max/ghaction-dump-context/releases)
- [Changelog](https://github.com/crazy-max/ghaction-dump-context/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crazy-max/ghaction-dump-context/compare/v1...v2)

---
updated-dependencies:
- dependency-name: crazy-max/ghaction-dump-context
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-13 19:58:55 +00:00
CrazyMax
766400ca14 Merge pull request #261 from crazy-max/update-build-push
update build-push-action to v4
2023-01-31 15:10:14 +01:00
CrazyMax
e2ffd4cc94 update build-push-action to v4
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-30 19:37:25 +01:00
CrazyMax
6c3ca5dfa6 Merge pull request #258 from crazy-max/ci-fix-json-job
ci: update json job
2023-01-17 17:03:30 +01:00
CrazyMax
235becadd8 ci: update json job
The step in the json job is no longer necessary since it is
already done by the output-env job.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-13 15:01:54 +01:00
CrazyMax
507c2f2dc5 Merge pull request #257 from crazy-max/env-output
Provide outputs as env vars
2023-01-13 14:33:40 +01:00
CrazyMax
04861f5102 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-13 11:46:25 +01:00
CrazyMax
6729545cde Provide outputs as env vars
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-13 11:46:25 +01:00
CrazyMax
05d22bf317 Merge pull request #256 from crazy-max/fix-readme
Fix README
2023-01-11 16:25:04 +01:00
CrazyMax
70b403b46b Fix README
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-11 16:17:34 +01:00
CrazyMax
9e6ae02878 Merge pull request #252 from docker/dependabot/npm_and_yarn/json5-2.2.3
Bump json5 from 2.2.0 to 2.2.3
2023-01-08 18:33:57 +01:00
dependabot[bot]
3d239e8b8a Bump json5 from 2.2.0 to 2.2.3
Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-06 09:54:33 +00:00
CrazyMax
7cb52e2750 Merge pull request #251 from chroju/set_timezone
Add tz attribute to handlebar date function
2023-01-06 10:54:03 +01:00
chroju
90a1d5cf21 Add tz attribute to handlebar date function
Signed-off-by: chroju <chroju@users.noreply.github.com>
2023-01-06 18:11:29 +09:00
CrazyMax
c98ac5e987 Merge pull request #249 from crazy-max/fix-readme
readme: fix badges
2022-12-19 21:11:06 +01:00
CrazyMax
44d853bc0a readme: fix badges
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-12-19 21:07:37 +01:00
CrazyMax
d1abf80723 Merge pull request #245 from docker/dependabot/npm_and_yarn/csv-parse-5.3.3
Bump csv-parse from 5.3.1 to 5.3.3
2022-12-19 21:05:43 +01:00
CrazyMax
3358a27538 update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-12-19 21:02:10 +01:00
CrazyMax
314ddf6d4a Merge pull request #242 from docker/dependabot/npm_and_yarn/minimatch-3.1.2
Bump minimatch from 3.0.4 to 3.1.2
2022-11-29 18:53:57 +01:00
dependabot[bot]
b91e8f52b0 Bump csv-parse from 5.3.1 to 5.3.3
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.3.1 to 5.3.3.
- [Release notes](https://github.com/adaltas/node-csv/releases)
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.3.3/packages/csv-parse)

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 19:04:37 +00:00
dependabot[bot]
fbac5f9bca Bump minimatch from 3.0.4 to 3.1.2
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-10 03:52:53 +00:00
CrazyMax
57396166ad Merge pull request #237 from docker/dependabot/npm_and_yarn/csv-parse-5.3.1
Bump csv-parse from 5.3.0 to 5.3.1
2022-10-17 21:51:54 +02:00
CrazyMax
473bdc561c update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-10-17 21:50:02 +02:00
dependabot[bot]
ebedea2c18 Bump csv-parse from 5.3.0 to 5.3.1
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.3.0 to 5.3.1.
- [Release notes](https://github.com/adaltas/node-csv/releases)
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.3.1/packages/csv-parse)

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-17 21:49:36 +02:00
Tõnis Tiigi
d00b20e38f Merge pull request #239 from crazy-max/github-sha
revert changes to set associated head sha on pull request event
2022-10-17 09:09:59 -07:00
CrazyMax
a99e71cdc7 revert changes to set associated head sha on pull request event
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-10-17 11:49:09 +02:00
39 changed files with 5965 additions and 2740 deletions

3
.eslintignore Normal file
View File

@@ -0,0 +1,3 @@
/dist/**
/coverage/**
/node_modules/**

View File

@@ -1,11 +1,12 @@
{ {
"env": { "env": {
"node": true, "node": true,
"es2021": true, "es6": true,
"jest/globals": true "jest": true
}, },
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:jest/recommended", "plugin:jest/recommended",
"plugin:prettier/recommended" "plugin:prettier/recommended"

1
.github/CODEOWNERS vendored
View File

@@ -1 +0,0 @@
* @crazy-max

3
.github/CODE_OF_CONDUCT.md vendored Normal file
View File

@@ -0,0 +1,3 @@
# Code of conduct
- [Moby community guidelines](https://github.com/moby/moby/blob/master/CONTRIBUTING.md#moby-community-guidelines)

101
.github/ISSUE_TEMPLATE/bug.yml vendored Normal file
View File

@@ -0,0 +1,101 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: Bug Report
description: Report a bug
labels:
- status/triage
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to report a bug!
If this is a security issue please report it to the [Docker Security team](mailto:security@docker.com).
- type: checkboxes
attributes:
label: Contributing guidelines
description: >
Make sure you've read the contributing guidelines before proceeding.
options:
- label: I've read the [contributing guidelines](https://github.com/docker/metadata-action/blob/master/.github/CONTRIBUTING.md) and wholeheartedly agree
required: true
- type: checkboxes
attributes:
label: "I've found a bug, and:"
description: |
Make sure that your request fulfills all of the following requirements.
If one requirement cannot be satisfied, explain in detail why.
options:
- label: The documentation does not mention anything about my problem
- label: There are no open or closed issues that are related to my problem
- type: textarea
attributes:
label: Description
description: >
Provide a brief description of the bug in 1-2 sentences.
validations:
required: true
- type: textarea
attributes:
label: Expected behaviour
description: >
Describe precisely what you'd expect to happen.
validations:
required: true
- type: textarea
attributes:
label: Actual behaviour
description: >
Describe precisely what is actually happening.
validations:
required: true
- type: input
attributes:
label: Repository URL
description: >
Enter the URL of the repository where you are experiencing the
issue. If your repository is private, provide a link to a minimal
repository that reproduces the issue.
- type: input
attributes:
label: Workflow run URL
description: >
Enter the URL of the GitHub Action workflow run if public (e.g.
`https://github.com/<user>/<repo>/actions/runs/<id>`)
- type: textarea
attributes:
label: YAML workflow
description: |
Provide the YAML of the workflow that's causing the issue.
Make sure to remove any sensitive information.
render: yaml
validations:
required: true
- type: textarea
attributes:
label: Workflow logs
description: >
[Attach](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/attaching-files)
the [log file of your workflow run](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
and make sure to remove any sensitive information.
- type: textarea
attributes:
label: BuildKit logs
description: >
If applicable, provide the [BuildKit container logs](https://docs.docker.com/build/ci/github-actions/configure-builder/#buildkit-container-logs)
render: text
- type: textarea
attributes:
label: Additional info
description: |
Provide any additional information that could be useful.

View File

@@ -1,34 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
---
### Behaviour
#### Steps to reproduce this issue
1.
2.
3.
#### Expected behaviour
> Tell us what should happen
#### Actual behaviour
> Tell us what happens instead
### Configuration
* Repository URL (if public):
* Build URL (if public):
```yml
# paste your YAML workflow file here and remove sensitive data
```
### Logs
> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
> and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.

9
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
blank_issues_enabled: true
contact_links:
- name: Questions and Discussions
url: https://github.com/docker/metadata-action/discussions/new
about: Use Github Discussions to ask questions and/or open discussion topics.
- name: Documentation
url: https://docs.docker.com/build/ci/github-actions/
about: Read the documentation.

15
.github/ISSUE_TEMPLATE/feature.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: Feature request
description: Missing functionality? Come tell us about it!
labels:
- kind/enhancement
- status/triage
body:
- type: textarea
id: description
attributes:
label: Description
description: What is the feature you want to see?
validations:
required: true

12
.github/SECURITY.md vendored Normal file
View File

@@ -0,0 +1,12 @@
# Reporting security issues
The project maintainers take security seriously. If you discover a security
issue, please bring it to their attention right away!
**Please _DO NOT_ file a public issue**, instead send your report privately to
[security@docker.com](mailto:security@docker.com).
Security reports are greatly appreciated, and we will publicly thank you for it.
We also like to send gifts&mdash;if you'd like Docker swag, make sure to let
us know. We currently do not offer a paid security bounty program, but are not
ruling it out in the future.

32
.github/SUPPORT.md vendored
View File

@@ -1,32 +0,0 @@
# Support [![](https://isitmaintained.com/badge/resolution/docker/metadata-action.svg)](https://isitmaintained.com/project/docker/metadata-action)
## Reporting an issue
Please do a search in [open issues](https://github.com/docker/metadata-action/issues?utf8=%E2%9C%93&q=) to see if the
issue or feature request has already been filed.
If you find your issue already exists, make relevant comments and add your
[reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place
of a "+1" comment.
:+1: - upvote
:-1: - downvote
If you cannot find an existing issue that describes your bug or feature, submit an issue using the guidelines below.
## Writing good bug reports and feature requests
File a single issue per problem and feature request.
* Do not enumerate multiple bugs or feature requests in the same issue.
* Do not add your issue as a comment to an existing issue unless it's for the identical input. Many issues look similar, but have different causes.
The more information you can provide, the more likely someone will be successful reproducing the issue and finding a fix.
You are now ready to [create a new issue](https://github.com/docker/metadata-action/issues/new/choose)!
## Closure policy
* Issues that don't have the information requested above (when applicable) will be closed immediately and the poster directed to the support guidelines.
* Issues that go a week without a response from original poster are subject to closure at our discretion.

View File

@@ -11,6 +11,7 @@ updates:
directory: "/" directory: "/"
schedule: schedule:
interval: "daily" interval: "daily"
versioning-strategy: "increase"
allow: allow:
- dependency-type: "production" - dependency-type: "production"
labels: labels:

View File

@@ -1,8 +1,12 @@
name: ci name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on: on:
schedule: schedule:
- cron: '0 */4 * * *' # every 4 hours - cron: '0 10 * * *'
push: push:
branches: branches:
- 'master' - 'master'
@@ -10,9 +14,6 @@ on:
tags: tags:
- 'v*.*.*' - 'v*.*.*'
pull_request: pull_request:
branches:
- 'master'
- 'releases/v*'
env: env:
DOCKER_IMAGE: localhost:5000/name/app DOCKER_IMAGE: localhost:5000/name/app
@@ -23,7 +24,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -37,6 +38,9 @@ jobs:
type=ref,event=tag type=ref,event=tag
type=ref,event=pr type=ref,event=pr
type=sha type=sha
-
name: Print envs
run: env|sort
tag-schedule: tag-schedule:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -51,7 +55,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -81,7 +85,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -109,7 +113,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -134,7 +138,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -151,7 +155,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -166,7 +170,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -185,7 +189,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
uses: ./ uses: ./
@@ -206,7 +210,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
@@ -235,7 +239,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: docker_meta id: docker_meta
@@ -254,15 +258,15 @@ jobs:
type=sha type=sha
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
with: with:
driver-opts: network=host driver-opts: network=host
- -
name: Build and push to local registry name: Build and push to local registry
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: ./test context: ./test
file: ./test/Dockerfile file: ./test/Dockerfile
@@ -282,14 +286,14 @@ jobs:
- -
name: Dump context name: Dump context
if: always() if: always()
uses: crazy-max/ghaction-dump-context@v1 uses: crazy-max/ghaction-dump-context@v2
bake: bake:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: docker_meta id: docker_meta
@@ -309,17 +313,18 @@ jobs:
type=sha type=sha
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- -
name: Build name: Build
uses: docker/bake-action@v2 uses: docker/bake-action@v4
with: with:
files: | files: |
./test/docker-bake.hcl ./test/docker-bake.hcl
${{ steps.docker_meta.outputs.bake-file }} ${{ steps.docker_meta.outputs.bake-file-tags }}
${{ steps.docker_meta.outputs.bake-file-labels }}
targets: | targets: |
release release
@@ -334,7 +339,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
@@ -346,7 +351,99 @@ jobs:
sep-tags: ${{ matrix.sep }} sep-tags: ${{ matrix.sep }}
- -
name: Tags name: Tags
uses: actions/github-script@v6 uses: actions/github-script@v7
with: with:
script: | script: |
console.log(`${{ steps.meta.outputs.tags }}`); console.log(`${{ steps.meta.outputs.tags }}`);
output-env:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
labels: |
maintainer=CrazyMax
-
name: Build
uses: docker/build-push-action@v5
with:
context: ./test
file: ./test/output.Dockerfile
build-args: |
DOCKER_METADATA_OUTPUT_VERSION
DOCKER_METADATA_OUTPUT_TAGS
DOCKER_METADATA_OUTPUT_LABELS
DOCKER_METADATA_OUTPUT_JSON
bake-annotations:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: docker_meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.12.0-rc1
-
name: Build
uses: docker/bake-action@v4
with:
files: |
./test/docker-bake.hcl
${{ steps.docker_meta.outputs.bake-file-tags }}
${{ steps.docker_meta.outputs.bake-file-annotations }}
targets: |
release
no-images:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
uses: ./
with:
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
-
name: Print envs
run: env|sort

View File

@@ -1,14 +1,15 @@
name: test name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on: on:
push: push:
branches: branches:
- 'master' - 'master'
- 'releases/v*' - 'releases/v*'
pull_request: pull_request:
branches:
- 'master'
- 'releases/v*'
jobs: jobs:
test: test:
@@ -16,15 +17,10 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
-
name: Validate
uses: docker/bake-action@v2
with:
targets: validate
- -
name: Test name: Test
uses: docker/bake-action@v2 uses: docker/bake-action@v4
with: with:
targets: test targets: test
- -

45
.github/workflows/validate.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: validate
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'master'
- 'releases/v*'
pull_request:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.targets.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Targets matrix
id: targets
run: |
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
validate:
runs-on: ubuntu-latest
needs:
- prepare
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.prepare.outputs.targets) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Validate
uses: docker/bake-action@v4
with:
targets: ${{ matrix.target }}

229
README.md
View File

@@ -1,6 +1,7 @@
[![GitHub release](https://img.shields.io/github/release/docker/metadata-action.svg?style=flat-square)](https://github.com/docker/metadata-action/releases/latest) [![GitHub release](https://img.shields.io/github/release/docker/metadata-action.svg?style=flat-square)](https://github.com/docker/metadata-action/releases/latest)
[![GitHub marketplace](https://img.shields.io/badge/marketplace-docker--metadata--action-blue?logo=github&style=flat-square)](https://github.com/marketplace/actions/docker-metadata-action) [![GitHub marketplace](https://img.shields.io/badge/marketplace-docker--metadata--action-blue?logo=github&style=flat-square)](https://github.com/marketplace/actions/docker-metadata-action)
[![Test workflow](https://img.shields.io/github/workflow/status/docker/metadata-action/test?label=test&logo=github&style=flat-square)](https://github.com/docker/metadata-action/actions?workflow=test) [![CI workflow](https://img.shields.io/github/actions/workflow/status/docker/metadata-action/ci.yml?branch=master&label=ci&logo=github&style=flat-square)](https://github.com/docker/metadata-action/actions?workflow=ci)
[![Test workflow](https://img.shields.io/github/actions/workflow/status/docker/metadata-action/test.yml?branch=master&label=test&logo=github&style=flat-square)](https://github.com/docker/metadata-action/actions?workflow=test)
[![Codecov](https://img.shields.io/codecov/c/github/docker/metadata-action?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/metadata-action) [![Codecov](https://img.shields.io/codecov/c/github/docker/metadata-action?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/metadata-action)
## About ## About
@@ -20,6 +21,8 @@ ___
* [Customizing](#customizing) * [Customizing](#customizing)
* [inputs](#inputs) * [inputs](#inputs)
* [outputs](#outputs) * [outputs](#outputs)
* [environment variables](#environment-variables)
* [`context` input](#context-input)
* [`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,10 +44,11 @@ ___
* [`{{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)
* [Annotations](#annotations)
* [Contributing](#contributing) * [Contributing](#contributing)
## Usage ## Usage
@@ -71,23 +75,23 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: name/app images: name/app
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@@ -125,11 +129,11 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: | images: |
name/app name/app
@@ -141,13 +145,13 @@ jobs:
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@@ -203,11 +207,11 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: | images: |
name/app name/app
@@ -219,7 +223,7 @@ jobs:
type=sha type=sha
- -
name: Build name: Build
uses: docker/bake-action@v2 uses: docker/bake-action@v3
with: with:
files: | files: |
./docker-bake.hcl ./docker-bake.hcl
@@ -227,8 +231,8 @@ jobs:
targets: build targets: build
``` ```
Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with Content of `${{ steps.meta.outputs.bake-file }}` file, combining tags and
`refs/tags/v1.2.3` ref: labels, will look like this with `refs/tags/v1.2.3` ref:
```json ```json
{ {
@@ -259,11 +263,27 @@ Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with
} }
``` ```
You can also use the `bake-file-tags` and `bake-file-labels` outputs if you
just want to use tags and/or labels respectively. The following example is
similar to the previous one:
```yaml
-
name: Build
uses: docker/bake-action@v3
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file-tags }}
${{ steps.meta.outputs.bake-file-labels }}
targets: build
```
## Customizing ## Customizing
### inputs ### inputs
Following inputs can be used as `step.with` keys The following inputs can be used as `step.with` keys:
> `List` type is a newline-delimited string > `List` type is a newline-delimited string
> ```yaml > ```yaml
@@ -273,27 +293,72 @@ Following inputs can be used as `step.with` keys
> org.opencontainers.image.vendor=MyCompany > org.opencontainers.image.vendor=MyCompany
> ``` > ```
| Name | Type | Description | | Name | Type | Description |
|---------------------|--------|----------------------------------------------------------| |---------------|--------|-------------------------------------------------------------------------------|
| `images` | List | List of Docker images to use as base name for tags | | `context` | String | Where to get context data. Allowed options are: `workflow` (default), `git`. |
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes | | `images` | List | List of Docker images to use as base name for tags |
| `flavor` | List | [Flavor](#flavor-input) to apply | | `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
| `labels` | List | List of custom labels | | `flavor` | List | [Flavor](#flavor-input) to apply |
| `sep-tags` | String | Separator to use for tags output (default `\n`) | | `labels` | List | List of custom labels |
| `sep-labels` | String | Separator to use for labels output (default `\n`) | | `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `bake-target` | String | Bake target name (default `docker-metadata-action`) | | `sep-labels` | String | Separator to use for labels output (default `\n`) |
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
### outputs ### outputs
Following outputs are available The following outputs are available:
| Name | Type | Description | | Name | Type | Description |
|---------------|---------|--------------------------------------------------------------------------------------------| |-------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `version` | String | Docker image version | | `version` | String | Docker image version |
| `tags` | String | Docker tags | | `tags` | String | Docker tags |
| `labels` | String | Docker labels | | `labels` | String | Docker labels |
| `json` | String | JSON output of tags and labels | | `annotations` | String | [Annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
| `bake-file` | File | [Bake file definition](https://docs.docker.com/build/customize/bake/file-definition/) path | | `json` | String | JSON output of tags and labels |
| `bake-file-tags` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with tags |
| `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
| `bake-file-annotations` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with [annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
Alternatively, each output is also exported as an environment variable:
* `DOCKER_METADATA_OUTPUT_VERSION`
* `DOCKER_METADATA_OUTPUT_TAGS`
* `DOCKER_METADATA_OUTPUT_LABELS`
* `DOCKER_METADATA_OUTPUT_ANNOTATIONS`
* `DOCKER_METADATA_OUTPUT_JSON`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_LABELS`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_ANNOTATIONS`
So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/):
```yaml
- uses: docker/build-push-action@v5
with:
build-args: |
DOCKER_METADATA_OUTPUT_JSON
```
### 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 |
| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
## `context` input
`context` defines where to get context metadata:
```yaml
# default
context: workflow
# or
context: git
```
* `workflow`: Get context metadata from the workflow (GitHub context). See https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
* `git`: Get context metadata from the workflow and overrides some of them with current Git context, such as `ref` and `sha`.
## `images` input ## `images` input
@@ -318,6 +383,8 @@ images: |
* `name=<string>` image base name * `name=<string>` image base name
* `enable=<true|false>` enable this entry (default `true`) * `enable=<true|false>` enable this entry (default `true`)
If `images` is empty, tags will be generated without base name.
## `flavor` input ## `flavor` input
`flavor` defines a global behavior for [`tags`](#tags-input): `flavor` defines a global behavior for [`tags`](#tags-input):
@@ -391,6 +458,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 +467,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 +839,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
@@ -804,13 +877,13 @@ that you can reuse them further in your workflow using the [`fromJSON` function]
```yaml ```yaml
- -
name: Docker meta name: Docker meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
id: meta id: meta
with: with:
images: name/app images: name/app
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
@@ -829,7 +902,7 @@ labels generated are not suitable, you can overwrite them like this:
- -
name: Docker meta name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: name/app images: name/app
labels: | labels: |
@@ -839,6 +912,70 @@ labels generated are not suitable, you can overwrite them like this:
org.opencontainers.image.vendor=MyCompany org.opencontainers.image.vendor=MyCompany
``` ```
### Annotations
Since Buildx 0.12, it is possible to set annotations to your image through the
`--annotation` flag.
With the [`build-push-action`](https://github.com/docker/build-push-action/),
you can set the `annotations` input with the value of the `annotations` output
of the `metadata-action`:
```yaml
-
name: Docker meta
uses: docker/metadata-action@v5
with:
images: name/app
-
name: Build and push
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
```
The same can be done with the [`bake-action`](https://github.com/docker/bake-action/):
```yaml
-
name: Docker meta
uses: docker/metadata-action@v5
with:
images: name/app
-
name: Build
uses: docker/bake-action@v3
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file-tags }}
${{ steps.meta.outputs.bake-file-annotations }}
targets: build
```
If you want to set specific level(s) for your annotations, you can use the
[`DOCKER_METADATA_ANNOTATIONS_LEVELS` environment variable](#environment-variables)
with a comma separated list of levels (defaults to `manifest`):
```yaml
-
name: Docker meta
uses: docker/metadata-action@v5
with:
images: name/app
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
-
name: Build and push
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
```
More information about annotations in the [BuildKit documentation](https://github.com/moby/buildkit/blob/master/docs/annotations.md).
## Contributing ## Contributing
Want to contribute? Awesome! You can find information about contributing to Want to contribute? Awesome! You can find information about contributing to

View File

@@ -3,7 +3,7 @@
## v2 to v3 ## v2 to v3
* Repository has been moved to docker org. Replace `crazy-max/ghaction-docker-meta@v2` * Repository has been moved to docker org. Replace `crazy-max/ghaction-docker-meta@v2`
with `docker/metadata-action@v4` with `docker/metadata-action@v5`
* The default bake target has been changed: `ghaction-docker-meta` > `docker-metadata-action` * The default bake target has been changed: `ghaction-docker-meta` > `docker-metadata-action`
## v1 to v2 ## v1 to v2
@@ -133,7 +133,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
@@ -143,13 +143,13 @@ jobs:
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@@ -177,23 +177,23 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: name/app images: name/app
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@@ -223,7 +223,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
@@ -236,13 +236,13 @@ jobs:
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@@ -270,11 +270,11 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: name/app images: name/app
tags: | tags: |
@@ -285,13 +285,13 @@ jobs:
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}

View File

@@ -0,0 +1,207 @@
import {jest} from '@jest/globals';
export const context = {
repo: {
owner: 'docker',
repo: 'actions-toolkit'
},
ref: 'refs/heads/master',
runId: 123,
payload: {
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
base_ref: null,
before: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
commits: [
{
author: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
committer: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
distinct: true,
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
message: 'hello dev',
timestamp: '2022-04-19T11:27:24+02:00',
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
}
],
compare: 'https://github.com/docker/test-docker-action/compare/5f3331d7f704...860c1904a1ce',
created: false,
deleted: false,
forced: false,
head_commit: {
author: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
committer: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
distinct: true,
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
message: 'hello dev',
timestamp: '2022-04-19T11:27:24+02:00',
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
},
organization: {
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
description: 'Docker helps developers bring their ideas to life by conquering the complexity of app development.',
events_url: 'https://api.github.com/orgs/docker/events',
hooks_url: 'https://api.github.com/orgs/docker/hooks',
id: 5429470,
issues_url: 'https://api.github.com/orgs/docker/issues',
login: 'docker',
members_url: 'https://api.github.com/orgs/docker/members{/member}',
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
public_members_url: 'https://api.github.com/orgs/docker/public_members{/member}',
repos_url: 'https://api.github.com/orgs/docker/repos',
url: 'https://api.github.com/orgs/docker'
},
pusher: {
email: 'github@crazymax.dev',
name: 'crazy-max'
},
ref: 'refs/heads/dev',
repository: {
allow_forking: true,
archive_url: 'https://api.github.com/repos/docker/test-docker-action/{archive_format}{/ref}',
archived: false,
assignees_url: 'https://api.github.com/repos/docker/test-docker-action/assignees{/user}',
blobs_url: 'https://api.github.com/repos/docker/test-docker-action/git/blobs{/sha}',
branches_url: 'https://api.github.com/repos/docker/test-docker-action/branches{/branch}',
clone_url: 'https://github.com/docker/test-docker-action.git',
collaborators_url: 'https://api.github.com/repos/docker/test-docker-action/collaborators{/collaborator}',
comments_url: 'https://api.github.com/repos/docker/test-docker-action/comments{/number}',
commits_url: 'https://api.github.com/repos/docker/test-docker-action/commits{/sha}',
compare_url: 'https://api.github.com/repos/docker/test-docker-action/compare/{base}...{head}',
contents_url: 'https://api.github.com/repos/docker/test-docker-action/contents/{+path}',
contributors_url: 'https://api.github.com/repos/docker/test-docker-action/contributors',
created_at: 1596792180,
default_branch: 'master',
deployments_url: 'https://api.github.com/repos/docker/test-docker-action/deployments',
description: 'Test "Docker" Actions',
disabled: false,
downloads_url: 'https://api.github.com/repos/docker/test-docker-action/downloads',
events_url: 'https://api.github.com/repos/docker/test-docker-action/events',
fork: false,
forks: 1,
forks_count: 1,
forks_url: 'https://api.github.com/repos/docker/test-docker-action/forks',
full_name: 'docker/test-docker-action',
git_commits_url: 'https://api.github.com/repos/docker/test-docker-action/git/commits{/sha}',
git_refs_url: 'https://api.github.com/repos/docker/test-docker-action/git/refs{/sha}',
git_tags_url: 'https://api.github.com/repos/docker/test-docker-action/git/tags{/sha}',
git_url: 'git://github.com/docker/test-docker-action.git',
has_downloads: true,
has_issues: true,
has_pages: false,
has_projects: true,
has_wiki: true,
homepage: '',
hooks_url: 'https://api.github.com/repos/docker/test-docker-action/hooks',
html_url: 'https://github.com/docker/test-docker-action',
id: 285789493,
is_template: false,
issue_comment_url: 'https://api.github.com/repos/docker/test-docker-action/issues/comments{/number}',
issue_events_url: 'https://api.github.com/repos/docker/test-docker-action/issues/events{/number}',
issues_url: 'https://api.github.com/repos/docker/test-docker-action/issues{/number}',
keys_url: 'https://api.github.com/repos/docker/test-docker-action/keys{/key_id}',
labels_url: 'https://api.github.com/repos/docker/test-docker-action/labels{/name}',
language: 'JavaScript',
languages_url: 'https://api.github.com/repos/docker/test-docker-action/languages',
license: {
key: 'mit',
name: 'MIT License',
node_id: 'MDc6TGljZW5zZTEz',
spdx_id: 'MIT',
url: 'https://api.github.com/licenses/mit'
},
master_branch: 'master',
merges_url: 'https://api.github.com/repos/docker/test-docker-action/merges',
milestones_url: 'https://api.github.com/repos/docker/test-docker-action/milestones{/number}',
mirror_url: null,
name: 'test-docker-action',
node_id: 'MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=',
notifications_url: 'https://api.github.com/repos/docker/test-docker-action/notifications{?since,all,participating}',
open_issues: 6,
open_issues_count: 6,
organization: 'docker',
owner: {
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
email: 'info@docker.com',
events_url: 'https://api.github.com/users/docker/events{/privacy}',
followers_url: 'https://api.github.com/users/docker/followers',
following_url: 'https://api.github.com/users/docker/following{/other_user}',
gists_url: 'https://api.github.com/users/docker/gists{/gist_id}',
gravatar_id: '',
html_url: 'https://github.com/docker',
id: 5429470,
login: 'docker',
name: 'docker',
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
organizations_url: 'https://api.github.com/users/docker/orgs',
received_events_url: 'https://api.github.com/users/docker/received_events',
repos_url: 'https://api.github.com/users/docker/repos',
site_admin: false,
starred_url: 'https://api.github.com/users/docker/starred{/owner}{/repo}',
subscriptions_url: 'https://api.github.com/users/docker/subscriptions',
type: 'Organization',
url: 'https://api.github.com/users/docker'
},
private: true,
pulls_url: 'https://api.github.com/repos/docker/test-docker-action/pulls{/number}',
pushed_at: 1650360446,
releases_url: 'https://api.github.com/repos/docker/test-docker-action/releases{/id}',
size: 796,
ssh_url: 'git@github.com:docker/test-docker-action.git',
stargazers: 0,
stargazers_count: 0,
stargazers_url: 'https://api.github.com/repos/docker/test-docker-action/stargazers',
statuses_url: 'https://api.github.com/repos/docker/test-docker-action/statuses/{sha}',
subscribers_url: 'https://api.github.com/repos/docker/test-docker-action/subscribers',
subscription_url: 'https://api.github.com/repos/docker/test-docker-action/subscription',
svn_url: 'https://github.com/docker/test-docker-action',
tags_url: 'https://api.github.com/repos/docker/test-docker-action/tags',
teams_url: 'https://api.github.com/repos/docker/test-docker-action/teams',
topics: [],
trees_url: 'https://api.github.com/repos/docker/test-docker-action/git/trees{/sha}',
updated_at: '2022-04-19T09:05:09Z',
url: 'https://github.com/docker/test-docker-action',
visibility: 'private',
watchers: 0,
watchers_count: 0
},
sender: {
avatar_url: 'https://avatars.githubusercontent.com/u/1951866?v=4',
events_url: 'https://api.github.com/users/crazy-max/events{/privacy}',
followers_url: 'https://api.github.com/users/crazy-max/followers',
following_url: 'https://api.github.com/users/crazy-max/following{/other_user}',
gists_url: 'https://api.github.com/users/crazy-max/gists{/gist_id}',
gravatar_id: '',
html_url: 'https://github.com/crazy-max',
id: 1951866,
login: 'crazy-max',
node_id: 'MDQ6VXNlcjE5NTE4NjY=',
organizations_url: 'https://api.github.com/users/crazy-max/orgs',
received_events_url: 'https://api.github.com/users/crazy-max/received_events',
repos_url: 'https://api.github.com/users/crazy-max/repos',
site_admin: false,
starred_url: 'https://api.github.com/users/crazy-max/starred{/owner}{/repo}',
subscriptions_url: 'https://api.github.com/users/crazy-max/subscriptions',
type: 'User',
url: 'https://api.github.com/users/crazy-max'
}
}
};
export const getOctokit = jest.fn();

View File

@@ -1,167 +1,126 @@
import {describe, expect, it, jest} from '@jest/globals'; import {afterEach, beforeEach, describe, expect, test, it, jest} from '@jest/globals';
import * as dotenv from 'dotenv';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import {Context} from '@actions/github/lib/context';
import {Git} from '@docker/actions-toolkit/lib/git';
import {GitHub} from '@docker/actions-toolkit/lib/github';
import * as context from '../src/context'; import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
jest.spyOn(context, 'tmpDir').mockImplementation((): string => { beforeEach(() => {
const tmpDir = path.join('/tmp/.docker-metadata-action-jest').split(path.sep).join(path.posix.sep); jest.clearAllMocks();
if (!fs.existsSync(tmpDir)) { jest.spyOn(GitHub, 'context', 'get').mockImplementation((): Context => {
fs.mkdirSync(tmpDir, {recursive: true}); return new Context();
}
return tmpDir;
});
describe('getInputList', () => {
it('single line correctly', async () => {
await setInput('foo', 'bar');
const res = context.getInputList('foo');
expect(res).toEqual(['bar']);
});
it('multiline correctly', async () => {
setInput('foo', 'bar\nbaz');
const res = context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
});
it('empty lines correctly', async () => {
setInput('foo', 'bar\n\nbaz');
const res = context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
});
it('comment correctly', async () => {
setInput('foo', 'bar\n#com\n"#taken"\nhello#comment\nbaz');
const res = context.getInputList('foo');
expect(res).toEqual(['bar', '#taken', 'hello', 'baz']);
});
it('comma correctly', async () => {
setInput('foo', 'bar,baz');
const res = context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
});
it('empty result correctly', async () => {
setInput('foo', 'bar,baz,');
const res = context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
});
it('different new lines correctly', async () => {
setInput('foo', 'bar\r\nbaz');
const res = context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
});
it('different new lines and comma correctly', async () => {
setInput('foo', 'bar\r\nbaz,bat');
const res = context.getInputList('foo');
expect(res).toEqual(['bar', 'baz', 'bat']);
});
it('multiline and ignoring comma correctly', async () => {
setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir');
const res = context.getInputList('cache-from', true);
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
});
it('different new lines and ignoring comma correctly', async () => {
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
const res = context.getInputList('cache-from', true);
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
});
it('multiline values', async () => {
setInput(
'secrets',
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
"MYSECRET=aaaaaaaa
bbbbbbb
ccccccccc"
FOO=bar`
);
const res = context.getInputList('secrets', true);
expect(res).toEqual([
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
`MYSECRET=aaaaaaaa
bbbbbbb
ccccccccc`,
'FOO=bar'
]);
});
it('multiline values with empty lines', async () => {
setInput(
'secrets',
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
"MYSECRET=aaaaaaaa
bbbbbbb
ccccccccc"
FOO=bar
"EMPTYLINE=aaaa
bbbb
ccc"`
);
const res = context.getInputList('secrets', true);
expect(res).toEqual([
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
`MYSECRET=aaaaaaaa
bbbbbbb
ccccccccc`,
'FOO=bar',
`EMPTYLINE=aaaa
bbbb
ccc`
]);
});
it('multiline values without quotes', async () => {
setInput(
'secrets',
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
MYSECRET=aaaaaaaa
bbbbbbb
ccccccccc
FOO=bar`
);
const res = context.getInputList('secrets', true);
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
});
it('multiline values escape quotes', async () => {
setInput(
'secrets',
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
"MYSECRET=aaaaaaaa
bbbb""bbb
ccccccccc"
FOO=bar`
);
const res = context.getInputList('secrets', true);
expect(res).toEqual([
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
`MYSECRET=aaaaaaaa
bbbb"bbb
ccccccccc`,
'FOO=bar'
]);
}); });
}); });
describe('asyncForEach', () => { describe('getInputs', () => {
it('executes async tasks sequentially', async () => { beforeEach(() => {
const testValues = [1, 2, 3, 4, 5]; process.env = Object.keys(process.env).reduce((object, key) => {
const results: number[] = []; if (!key.startsWith('INPUT_')) {
object[key] = process.env[key];
}
return object;
}, {});
});
await context.asyncForEach(testValues, async value => { // prettier-ignore
results.push(value); test.each([
[
0,
new Map<string, string>([
['images', 'moby/buildkit\nghcr.io/moby/mbuildkit'],
]),
{
context: ContextSource.workflow,
bakeTarget: 'docker-metadata-action',
flavor: [],
githubToken: '',
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
labels: [],
sepLabels: '\n',
sepTags: '\n',
tags: [],
} as Inputs
],
[
1,
new Map<string, string>([
['bake-target', 'metadata'],
['images', 'moby/buildkit'],
['sep-labels', ','],
['sep-tags', ','],
]),
{
context: ContextSource.workflow,
bakeTarget: 'metadata',
flavor: [],
githubToken: '',
images: ['moby/buildkit'],
labels: [],
sepLabels: ',',
sepTags: ',',
tags: [],
} as Inputs
],
[
2,
new Map<string, string>([
['images', 'moby/buildkit\n#comment\nghcr.io/moby/mbuildkit'],
]),
{
context: ContextSource.workflow,
bakeTarget: 'docker-metadata-action',
flavor: [],
githubToken: '',
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
labels: [],
sepLabels: '\n',
sepTags: '\n',
tags: [],
} as Inputs
],
])(
'[%d] given %p as inputs, returns %p',
async (num: number, inputs: Map<string, string>, expected: Inputs) => {
inputs.forEach((value: string, name: string) => {
setInput(name, value);
});
expect(await getInputs()).toEqual(expected);
}
);
});
describe('getContext', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
process.env = {
...originalEnv,
...dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures/event_create_branch.env')))
};
});
afterEach(() => {
process.env = originalEnv;
});
it('workflow', async () => {
const context = await getContext(ContextSource.workflow);
expect(context.ref).toEqual('refs/heads/dev');
expect(context.sha).toEqual('5f3331d7f7044c18ca9f12c77d961c4d7cf3276a');
});
it('git', async () => {
jest.spyOn(Git, 'context').mockImplementation((): Promise<Context> => {
return Promise.resolve({
ref: 'refs/heads/git-test',
sha: 'git-test-sha'
} as Context);
}); });
const context = await getContext(ContextSource.git);
expect(results).toEqual(testValues); expect(context.ref).toEqual('refs/heads/git-test');
expect(context.sha).toEqual('git-test-sha');
}); });
}); });

View File

@@ -1,4 +1,5 @@
import {describe, expect, test} from '@jest/globals'; import {describe, expect, test} from '@jest/globals';
import {Flavor, Transform} from '../src/flavor'; import {Flavor, Transform} from '../src/flavor';
describe('transform', () => { describe('transform', () => {

View File

@@ -1,14 +0,0 @@
import {describe, expect, jest, it} from '@jest/globals';
import * as github from '../src/github';
import * as repoFixture from './fixtures/repo.json';
jest.spyOn(github, 'repo').mockImplementation((): Promise<github.ReposGetResponseData> => {
return <Promise<github.ReposGetResponseData>>(repoFixture as unknown);
});
describe('repo', () => {
it('returns GitHub repository', async () => {
const repo = await github.repo(process.env.GITHUB_TOKEN || '');
expect(repo.name).not.toBeNull();
});
});

View File

@@ -1,4 +1,5 @@
import {describe, expect, test} from '@jest/globals'; import {describe, expect, test} from '@jest/globals';
import {Transform, Image} from '../src/image'; import {Transform, Image} from '../src/image';
describe('transform', () => { describe('transform', () => {
@@ -86,7 +87,7 @@ describe('transform', () => {
[ [
[`name/foo,name=name/bar,enable=true`], undefined, true [`name/foo,name=name/bar,enable=true`], undefined, true
] ]
])('given %p', async (l: string[], expected: Image[], invalid: boolean) => { ])('given %p', async (l: string[], expected: Image[] | undefined, invalid: boolean) => {
try { try {
const images = Transform(l); const images = Transform(l);
expect(images).toEqual(expected); expect(images).toEqual(expected);

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
import {describe, expect, test} from '@jest/globals'; import {describe, expect, test} from '@jest/globals';
import {Transform, Parse, Tag, Type, RefEvent, ShaFormat, DefaultPriorities} from '../src/tag'; import {Transform, Parse, Tag, Type, RefEvent, ShaFormat, DefaultPriorities} from '../src/tag';
describe('transform', () => { describe('transform', () => {
@@ -126,6 +127,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}}`,
{ {

View File

@@ -7,9 +7,13 @@ branding:
color: 'blue' color: 'blue'
inputs: inputs:
context:
description: 'Where to get context data. Allowed options are "workflow" (default), "git".'
default: "workflow"
required: true
images: images:
description: 'List of Docker images to use as base name for tags' description: 'List of Docker images to use as base name for tags'
required: true required: false
tags: tags:
description: 'List of tags as key-value pair attributes' description: 'List of tags as key-value pair attributes'
required: false required: false
@@ -40,11 +44,19 @@ outputs:
description: 'Generated Docker tags' description: 'Generated Docker tags'
labels: labels:
description: 'Generated Docker labels' description: 'Generated Docker labels'
bake-file: annotations:
description: 'Bake definiton file' description: 'Generated annotations'
json: json:
description: 'JSON output of tags and labels' description: 'JSON output of tags and labels'
bake-file-tags:
description: 'Bake definition file with tags'
bake-file-labels:
description: 'Bake definition file with labels'
bake-file-annotations:
description: 'Bake definiton file with annotations'
bake-file:
description: 'Bake definition file with tags and labels'
runs: runs:
using: 'node16' using: 'node20'
main: 'dist/index.js' main: 'dist/index.js'

View File

@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
ARG NODE_VERSION=16 ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine AS base FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git RUN apk add --no-cache cpio findutils git
@@ -16,14 +16,14 @@ COPY --from=deps /vendor /
FROM deps AS vendor-validate FROM deps AS vendor-validate
RUN --mount=type=bind,target=.,rw <<EOT RUN --mount=type=bind,target=.,rw <<EOT
set -e set -e
git add -A git add -A
cp -rf /vendor/* . cp -rf /vendor/* .
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"' echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
git status --porcelain -- yarn.lock git status --porcelain -- yarn.lock
exit 1 exit 1
fi fi
EOT EOT
FROM deps AS build FROM deps AS build
@@ -36,14 +36,14 @@ COPY --from=build /out /
FROM build AS build-validate FROM build AS build-validate
RUN --mount=type=bind,target=.,rw <<EOT RUN --mount=type=bind,target=.,rw <<EOT
set -e set -e
git add -A git add -A
cp -rf /out/* . cp -rf /out/* .
if [ -n "$(git status --porcelain -- dist)" ]; then if [ -n "$(git status --porcelain -- dist)" ]; then
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"' echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
git status --porcelain -- dist git status --porcelain -- dist
exit 1 exit 1
fi fi
EOT EOT
FROM deps AS format FROM deps AS format
@@ -65,7 +65,7 @@ ENV RUNNER_TEMP=/tmp/github_runner
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run test --coverageDirectory=/tmp/coverage yarn run test --coverage --coverageDirectory=/tmp/coverage
FROM scratch AS test-coverage FROM scratch AS test-coverage
COPY --from=test /tmp/coverage / COPY --from=test /tmp/coverage /

54
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

1307
dist/licenses.txt generated vendored

File diff suppressed because it is too large Load Diff

2
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,21 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-metadata-action-'));
process.env = Object.assign({}, process.env, {
TEMP: tmpDir,
GITHUB_REPOSITORY: 'docker/metadata-action',
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
}) as {
[key: string]: string;
};
module.exports = { module.exports = {
clearMocks: true, clearMocks: true,
testEnvironment: 'node',
moduleFileExtensions: ['js', 'ts'], moduleFileExtensions: ['js', 'ts'],
setupFiles: ['dotenv/config'], setupFiles: ['dotenv/config'],
testMatch: ['**/*.test.ts'], testMatch: ['**/*.test.ts'],
@@ -9,5 +25,7 @@ module.exports = {
moduleNameMapper: { moduleNameMapper: {
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs' '^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
}, },
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'],
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__mocks__/', '__tests__/'],
verbose: true verbose: true
}; };

View File

@@ -4,9 +4,13 @@
"main": "lib/main.js", "main": "lib/main.js",
"scripts": { "scripts": {
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt", "build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
"lint": "eslint src/**/*.ts __tests__/**/*.ts", "lint": "yarn run prettier && yarn run eslint",
"format": "eslint --fix src/**/*.ts __tests__/**/*.ts", "format": "yarn run prettier:fix && yarn run eslint:fix",
"test": "jest --coverage", "eslint": "eslint --max-warnings=0 .",
"eslint:fix": "eslint --fix .",
"prettier": "prettier --check \"./**/*.ts\"",
"prettier:fix": "prettier --write \"./**/*.ts\"",
"test": "jest",
"all": "yarn run build && yarn run format && yarn test" "all": "yarn run build && yarn run format && yarn test"
}, },
"repository": { "repository": {
@@ -20,39 +24,35 @@
"tag", "tag",
"label" "label"
], ],
"author": "Docker", "author": "Docker Inc.",
"contributors": [
{
"name": "CrazyMax",
"url": "https://crazymax.dev"
}
],
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.1",
"@actions/github": "^5.1.1", "@actions/github": "^6.0.0",
"@docker/actions-toolkit": "^0.14.0",
"@renovate/pep440": "^1.0.0", "@renovate/pep440": "^1.0.0",
"csv-parse": "^5.3.0", "csv-parse": "^5.5.2",
"handlebars": "^4.7.7", "handlebars": "^4.7.8",
"moment": "^2.29.4", "moment": "^2.29.4",
"semver": "^7.3.7" "moment-timezone": "^0.5.43",
"semver": "^7.5.4"
}, },
"devDependencies": { "devDependencies": {
"@types/csv-parse": "^1.2.2", "@types/csv-parse": "^1.2.2",
"@types/node": "^16.11.26", "@types/node": "^20.5.9",
"@types/semver": "^7.3.9", "@types/semver": "^7.5.1",
"@typescript-eslint/eslint-plugin": "^5.14.0", "@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^5.14.0", "@typescript-eslint/parser": "^6.6.0",
"@vercel/ncc": "^0.33.3", "@vercel/ncc": "^0.38.0",
"dotenv": "^16.0.0", "dotenv": "^16.3.1",
"eslint": "^8.11.0", "eslint": "^8.48.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^26.1.1", "eslint-plugin-jest": "^27.2.3",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^5.0.0",
"jest": "^27.2.5", "jest": "^29.6.4",
"prettier": "^2.3.1", "prettier": "^3.0.3",
"ts-jest": "^27.1.2", "ts-jest": "^29.1.1",
"ts-node": "^10.7.0", "ts-node": "^10.9.1",
"typescript": "^4.4.4" "typescript": "^5.2.2"
} }
} }

View File

@@ -1,12 +1,11 @@
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
import {parse} from 'csv-parse/sync'; import {Context} from '@actions/github/lib/context';
import {Util} from '@docker/actions-toolkit/lib/util';
let _tmpDir: string; import {Git} from '@docker/actions-toolkit/lib/git';
import {GitHub} from '@docker/actions-toolkit/lib/github';
export interface Inputs { export interface Inputs {
context: ContextSource;
images: string[]; images: string[];
tags: string[]; tags: string[];
flavor: string[]; flavor: string[];
@@ -17,19 +16,13 @@ export interface Inputs {
githubToken: string; githubToken: string;
} }
export function tmpDir(): string {
if (!_tmpDir) {
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-metadata-action-')).split(path.sep).join(path.posix.sep);
}
return _tmpDir;
}
export function getInputs(): Inputs { export function getInputs(): Inputs {
return { return {
images: getInputList('images', true), context: (core.getInput('context') || ContextSource.workflow) as ContextSource,
tags: getInputList('tags', true), images: Util.getInputList('images', {ignoreComma: true, comment: '#'}),
flavor: getInputList('flavor', true), tags: Util.getInputList('tags', {ignoreComma: true, comment: '#'}),
labels: getInputList('labels', true), flavor: Util.getInputList('flavor', {ignoreComma: true, comment: '#'}),
labels: Util.getInputList('labels', {ignoreComma: true, comment: '#'}),
sepTags: core.getInput('sep-tags', {trimWhitespace: false}) || `\n`, sepTags: core.getInput('sep-tags', {trimWhitespace: false}) || `\n`,
sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`, sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`,
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`, bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
@@ -37,38 +30,44 @@ export function getInputs(): Inputs {
}; };
} }
export function getInputList(name: string, ignoreComma?: boolean): string[] { export enum ContextSource {
const res: Array<string> = []; workflow = 'workflow',
git = 'git'
const items = core.getInput(name);
if (items == '') {
return res;
}
const records = parse(items, {
columns: false,
relaxQuotes: true,
comment: '#',
relaxColumnCount: true,
skipEmptyLines: true
});
for (const record of records as Array<string[]>) {
if (record.length == 1) {
res.push(record[0]);
continue;
} else if (!ignoreComma) {
res.push(...record);
continue;
}
res.push(record.join(','));
}
return res.filter(item => item).map(pat => pat.trim());
} }
export const asyncForEach = async (array, callback) => { export async function getContext(source: ContextSource): Promise<Context> {
for (let index = 0; index < array.length; index++) { switch (source) {
await callback(array[index], index, array); case ContextSource.workflow:
return getContextFromWorkflow();
case ContextSource.git:
return await getContextFromGit();
default:
throw new Error(`Invalid context source: ${source}`);
} }
}; }
function getContextFromWorkflow(): Context {
const context = GitHub.context;
// Needs to override Git reference with pr ref instead of upstream branch ref
// for pull_request_target event
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
if (/pull_request_target/.test(context.eventName)) {
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) {
context.sha = context.payload.pull_request.head.sha;
}
}
return context;
}
async function getContextFromGit(): Promise<Context> {
return await Git.context();
}

View File

@@ -1,16 +0,0 @@
import * as github from '@actions/github';
import {Context} from '@actions/github/lib/context';
import {components as OctoOpenApiTypes} from '@octokit/openapi-types';
export type ReposGetResponseData = OctoOpenApiTypes['schemas']['repository'];
export function context(): Context {
return github.context;
}
export async function repo(token: string): Promise<ReposGetResponseData> {
return github
.getOctokit(token)
.rest.repos.get({...github.context.repo})
.then(response => response.data as ReposGetResponseData);
}

View File

@@ -1,34 +1,39 @@
import * as fs from 'fs'; import * as fs from 'fs';
import {getInputs, Inputs} from './context';
import * as github from './github';
import {Meta, Version} from './meta';
import * as core from '@actions/core'; import * as core from '@actions/core';
import {Context} from '@actions/github/lib/context'; import * as actionsToolkit from '@docker/actions-toolkit';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
async function run() { import {getContext, getInputs, Inputs} from './context';
try { import {Meta, Version} from './meta';
const inputs: Inputs = await getInputs();
if (inputs.images.length == 0) {
throw new Error(`images input required`);
}
const context: Context = github.context(); function setOutput(name: string, value: string) {
const repo: github.ReposGetResponseData = await github.repo(inputs.githubToken); core.setOutput(name, value);
core.startGroup(`Context info`); core.exportVariable(`DOCKER_METADATA_OUTPUT_${name.replace(/\W/g, '_').toUpperCase()}`, value);
core.info(`eventName: ${context.eventName}`); }
core.info(`sha: ${context.sha}`);
core.info(`ref: ${context.ref}`); actionsToolkit.run(
core.info(`workflow: ${context.workflow}`); // main
core.info(`action: ${context.action}`); async () => {
core.info(`actor: ${context.actor}`); const inputs: Inputs = getInputs();
core.info(`runNumber: ${context.runNumber}`); const toolkit = new Toolkit({githubToken: inputs.githubToken});
core.info(`runId: ${context.runId}`); const context = await getContext(inputs.context);
core.endGroup(); const repo = await toolkit.github.repoData();
await core.group(`Context info`, async () => {
core.info(`eventName: ${context.eventName}`);
core.info(`sha: ${context.sha}`);
core.info(`ref: ${context.ref}`);
core.info(`workflow: ${context.workflow}`);
core.info(`action: ${context.action}`);
core.info(`actor: ${context.actor}`);
core.info(`runNumber: ${context.runNumber}`);
core.info(`runId: ${context.runId}`);
});
if (core.isDebug()) { if (core.isDebug()) {
core.startGroup(`Webhook payload`); await core.group(`Webhook payload`, async () => {
core.info(JSON.stringify(context.payload, null, 2)); core.info(JSON.stringify(context.payload, null, 2));
core.endGroup(); });
} }
const meta: Meta = new Meta(inputs, context, repo); const meta: Meta = new Meta(inputs, context, repo);
@@ -37,50 +42,70 @@ async function run() {
if (meta.version.main == undefined || meta.version.main.length == 0) { if (meta.version.main == undefined || meta.version.main.length == 0) {
core.warning(`No Docker image version has been generated. Check tags input.`); core.warning(`No Docker image version has been generated. Check tags input.`);
} else { } else {
core.startGroup(`Docker image version`); await core.group(`Docker image version`, async () => {
core.info(version.main || ''); core.info(version.main || '');
core.endGroup(); });
} }
core.setOutput('version', version.main || ''); setOutput('version', version.main || '');
// Docker tags // Docker tags
const tags: Array<string> = meta.getTags(); const tags: Array<string> = meta.getTags();
if (tags.length == 0) { if (tags.length == 0) {
core.warning('No Docker tag has been generated. Check tags input.'); core.warning('No Docker tag has been generated. Check tags input.');
} else { } else {
core.startGroup(`Docker tags`); await core.group(`Docker tags`, async () => {
for (const tag of tags) { for (const tag of tags) {
core.info(tag); core.info(tag);
} }
core.endGroup(); });
} }
core.setOutput('tags', tags.join(inputs.sepTags)); setOutput('tags', tags.join(inputs.sepTags));
// Docker labels // Docker labels
const labels: Array<string> = meta.getLabels(); const labels: Array<string> = meta.getLabels();
core.startGroup(`Docker labels`); await core.group(`Docker labels`, async () => {
for (const label of labels) { for (const label of labels) {
core.info(label); core.info(label);
}
setOutput('labels', labels.join(inputs.sepLabels));
});
// Annotations
const alevels = process.env.DOCKER_METADATA_ANNOTATIONS_LEVELS || 'manifest';
if (labels.length > 0) {
await core.group(`Annotations`, async () => {
const annotations: Array<string> = [];
for (const level of alevels.split(',')) {
annotations.push(
...labels.map(label => {
const v = `${level}:${label}`;
core.info(v);
return v;
})
);
}
setOutput(`annotations`, annotations.join(inputs.sepLabels));
});
} }
core.endGroup();
core.setOutput('labels', labels.join(inputs.sepLabels));
// JSON // JSON
const jsonOutput = meta.getJSON(); const jsonOutput = meta.getJSON(alevels.split(','));
core.startGroup(`JSON output`); await core.group(`JSON output`, async () => {
core.info(JSON.stringify(jsonOutput, null, 2)); core.info(JSON.stringify(jsonOutput, null, 2));
core.endGroup(); setOutput('json', JSON.stringify(jsonOutput));
core.setOutput('json', jsonOutput); });
// Bake file definition // Bake files
const bakeFile: string = meta.getBakeFile(); for (const kind of ['tags', 'labels', 'annotations:' + alevels]) {
core.startGroup(`Bake file definition`); const outputName = kind.split(':')[0];
core.info(fs.readFileSync(bakeFile, 'utf8')); const bakeFile: string = meta.getBakeFile(kind);
core.endGroup(); await core.group(`Bake file definition (${outputName})`, async () => {
core.setOutput('bake-file', bakeFile); core.info(fs.readFileSync(bakeFile, 'utf8'));
} catch (error) { setOutput(`bake-file-${outputName}`, bakeFile);
core.setFailed(error.message); });
}
// Bake file with tags and labels
setOutput(`bake-file`, meta.getBakeFileTagsLabels());
} }
} );
run();

View File

@@ -1,16 +1,18 @@
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 * as core from '@actions/core';
import {ReposGetResponseData} from './github'; import {Context} from '@actions/github/lib/context';
import {Context as ToolkitContext} from '@docker/actions-toolkit/lib/context';
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
import {Inputs} from './context';
import * as icl from './image'; import * as icl from './image';
import * as tcl from './tag'; import * as tcl from './tag';
import * as fcl from './flavor'; import * as fcl from './flavor';
import * as core from '@actions/core';
import {Context} from '@actions/github/lib/context';
export interface Version { export interface Version {
main: string | undefined; main: string | undefined;
@@ -23,24 +25,13 @@ export class Meta {
private readonly inputs: Inputs; private readonly inputs: Inputs;
private readonly context: Context; private readonly context: Context;
private readonly repo: ReposGetResponseData; private readonly repo: GitHubRepo;
private readonly images: icl.Image[]; private readonly images: icl.Image[];
private readonly tags: tcl.Tag[]; private readonly tags: tcl.Tag[];
private readonly flavor: fcl.Flavor; private readonly flavor: fcl.Flavor;
private readonly date: Date; private readonly date: Date;
constructor(inputs: Inputs, context: Context, repo: ReposGetResponseData) { constructor(inputs: Inputs, context: Context, repo: GitHubRepo) {
// Needs to override Git reference with pr ref instead of upstream branch ref
// for pull_request_target event
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
if (/pull_request_target/.test(context.eventName)) {
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) {
context.sha = context.payload.pull_request.head.sha;
}
this.inputs = inputs; this.inputs = inputs;
this.context = context; this.context = context;
this.repo = repo; this.repo = repo;
@@ -124,8 +115,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
@@ -152,7 +154,7 @@ export class Meta {
let latest = false; let latest = false;
const sver = semver.parse(vraw, { const sver = semver.parse(vraw, {
includePrerelease: true loose: true
}); });
if (semver.prerelease(vraw)) { if (semver.prerelease(vraw)) {
if (Meta.isRawStatement(tag.attrs['pattern'])) { if (Meta.isRawStatement(tag.attrs['pattern'])) {
@@ -355,59 +357,70 @@ export class Meta {
} }
private setGlobalExp(val): string { private setGlobalExp(val): string {
const ctx = this.context; const context = this.context;
const currentDate = this.date; const currentDate = this.date;
return handlebars.compile(val)({ return handlebars.compile(val)({
branch: function () { branch: function () {
if (!/^refs\/heads\//.test(ctx.ref)) { if (!/^refs\/heads\//.test(context.ref)) {
return ''; return '';
} }
return ctx.ref.replace(/^refs\/heads\//g, ''); return context.ref.replace(/^refs\/heads\//g, '');
}, },
tag: function () { tag: function () {
if (!/^refs\/tags\//.test(ctx.ref)) { if (!/^refs\/tags\//.test(context.ref)) {
return ''; return '';
} }
return ctx.ref.replace(/^refs\/tags\//g, ''); return context.ref.replace(/^refs\/tags\//g, '');
}, },
sha: function () { sha: function () {
return ctx.sha.substring(0, 7); return context.sha.substring(0, 7);
}, },
base_ref: function () { base_ref: function () {
if (/^refs\/tags\//.test(ctx.ref) && ctx.payload?.base_ref != undefined) { if (/^refs\/tags\//.test(context.ref) && context.payload?.base_ref != undefined) {
return ctx.payload.base_ref.replace(/^refs\/heads\//g, ''); return context.payload.base_ref.replace(/^refs\/heads\//g, '');
} }
// FIXME: keep this for backward compatibility even if doesn't always seem // FIXME: keep this for backward compatibility even if doesn't always seem
// to return the expected branch. See the comment below. // to return the expected branch. See the comment below.
if (/^refs\/pull\//.test(ctx.ref) && ctx.payload?.pull_request?.base?.ref != undefined) { if (/^refs\/pull\//.test(context.ref) && context.payload?.pull_request?.base?.ref != undefined) {
return ctx.payload.pull_request.base.ref; return context.payload.pull_request.base.ref;
} }
return ''; return '';
}, },
is_default_branch: function () { is_default_branch: function () {
const branch = ctx.ref.replace(/^refs\/heads\//g, ''); const branch = context.ref.replace(/^refs\/heads\//g, '');
// TODO: "base_ref" is available in the push payload but doesn't always seem to // TODO: "base_ref" is available in the push payload but doesn't always seem to
// return the expected branch when the push tag event occurs. It's also not // return the expected branch when the push tag event occurs. It's also not
// documented in GitHub docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push // documented in GitHub docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push
// more context: https://github.com/docker/metadata-action/pull/192#discussion_r854673012 // more context: https://github.com/docker/metadata-action/pull/192#discussion_r854673012
// if (/^refs\/tags\//.test(ctx.ref) && ctx.payload?.base_ref != undefined) { // if (/^refs\/tags\//.test(context.ref) && context.payload?.base_ref != undefined) {
// branch = ctx.payload.base_ref.replace(/^refs\/heads\//g, ''); // branch = context.payload.base_ref.replace(/^refs\/heads\//g, '');
// } // }
if (branch == undefined || branch.length == 0) { if (branch == undefined || branch.length == 0) {
return 'false'; return 'false';
} }
if (ctx.payload?.repository?.default_branch == branch) { if (context.payload?.repository?.default_branch == branch) {
return 'true'; return 'true';
} }
// following events always trigger for last commit on default branch // following events always trigger for last commit on default branch
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows // https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
if (/create/.test(ctx.eventName) || /discussion/.test(ctx.eventName) || /issues/.test(ctx.eventName) || /schedule/.test(ctx.eventName)) { if (/create/.test(context.eventName) || /discussion/.test(context.eventName) || /issues/.test(context.eventName) || /schedule/.test(context.eventName)) {
return 'true'; return 'true';
} }
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);
} }
}); });
} }
@@ -427,16 +440,29 @@ export class Meta {
if (!this.version.main) { if (!this.version.main) {
return []; return [];
} }
const tags: Array<string> = [];
for (const imageName of this.getImageNames()) { const generateTags = (imageName: string, version: string): Array<string> => {
tags.push(`${imageName}:${this.version.main}`); const tags: Array<string> = [];
const prefix = imageName !== '' ? `${imageName}:` : '';
tags.push(`${prefix}${version}`);
for (const partial of this.version.partial) { for (const partial of this.version.partial) {
tags.push(`${imageName}:${partial}`); tags.push(`${prefix}${partial}`);
} }
if (this.version.latest) { if (this.version.latest) {
const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`; const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`;
tags.push(`${imageName}:${Meta.sanitizeTag(latestTag)}`); tags.push(`${prefix}${Meta.sanitizeTag(latestTag)}`);
} }
return tags;
};
const tags: Array<string> = [];
const images = this.getImageNames();
if (images.length > 0) {
for (const imageName of images) {
tags.push(...generateTags(imageName, this.version.main));
}
} else {
tags.push(...generateTags('', this.version.main));
} }
return tags; return tags;
} }
@@ -453,10 +479,25 @@ export class Meta {
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}` `org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
]; ];
labels.push(...this.inputs.labels); labels.push(...this.inputs.labels);
return labels;
return Array.from(
new Map<string, string>(
labels
.map(label => label.split('='))
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.filter(([_key, ...values]) => values.length > 0)
.map(([key, ...values]) => [key, values.join('=')] as [string, string])
)
)
.sort((a, b) => a[0].localeCompare(b[0]))
.map(([key, value]) => `${key}=${value}`);
} }
public getJSON(): unknown { public getJSON(alevels: string[]): unknown {
const annotations: Array<string> = [];
for (const level of alevels) {
annotations.push(...this.getLabels().map(label => `${level}:${label}`));
}
return { return {
tags: this.getTags(), tags: this.getTags(),
labels: this.getLabels().reduce((res, label) => { labels: this.getLabels().reduce((res, label) => {
@@ -466,12 +507,46 @@ export class Meta {
} }
res[matches[1]] = matches[2]; res[matches[1]] = matches[2];
return res; return res;
}, {}) }, {}),
annotations: annotations
}; };
} }
public getBakeFile(): string { public getBakeFile(kind: string): string {
const bakeFile = path.join(tmpDir(), 'docker-metadata-action-bake.json').split(path.sep).join(path.posix.sep); if (kind == 'tags') {
return this.generateBakeFile(kind, {
tags: this.getTags(),
args: {
DOCKER_META_IMAGES: this.getImageNames().join(','),
DOCKER_META_VERSION: this.version.main
}
});
} else if (kind == 'labels') {
return this.generateBakeFile(kind, {
labels: this.getLabels().reduce((res, label) => {
const matches = label.match(/([^=]*)=(.*)/);
if (!matches) {
return res;
}
res[matches[1]] = matches[2];
return res;
}, {})
});
} else if (kind.startsWith('annotations:')) {
const name = kind.split(':')[0];
const annotations: Array<string> = [];
for (const level of kind.split(':')[1].split(',')) {
annotations.push(...this.getLabels().map(label => `${level}:${label}`));
}
return this.generateBakeFile(name, {
annotations: annotations
});
}
throw new Error(`Unknown bake file type: ${kind}`);
}
public getBakeFileTagsLabels(): string {
const bakeFile = path.join(ToolkitContext.tmpDir(), 'docker-metadata-action-bake.json');
fs.writeFileSync( fs.writeFileSync(
bakeFile, bakeFile,
JSON.stringify( JSON.stringify(
@@ -498,7 +573,12 @@ export class Meta {
2 2
) )
); );
return bakeFile;
}
private generateBakeFile(name: string, dt): string {
const bakeFile = path.join(ToolkitContext.tmpDir(), `docker-metadata-action-bake-${name}.json`);
fs.writeFileSync(bakeFile, JSON.stringify({target: {[this.inputs.bakeTarget]: dt}}, null, 2));
return bakeFile; return bakeFile;
} }

View File

@@ -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];

12
test/output.Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
# syntax=docker/dockerfile:1
FROM alpine
RUN apk add --no-cache coreutils jq
ARG DOCKER_METADATA_OUTPUT_VERSION
ARG DOCKER_METADATA_OUTPUT_TAGS
ARG DOCKER_METADATA_OUTPUT_LABELS
ARG DOCKER_METADATA_OUTPUT_JSON
RUN printenv DOCKER_METADATA_OUTPUT_VERSION
RUN printenv DOCKER_METADATA_OUTPUT_TAGS
RUN printenv DOCKER_METADATA_OUTPUT_LABELS
RUN printenv DOCKER_METADATA_OUTPUT_JSON
RUN echo $DOCKER_METADATA_OUTPUT_JSON | jq

View File

@@ -1,20 +1,22 @@
{ {
"compilerOptions": { "compilerOptions": {
"esModuleInterop": true,
"target": "es6", "target": "es6",
"module": "commonjs", "module": "commonjs",
"strict": true,
"newLine": "lf", "newLine": "lf",
"outDir": "./lib", "outDir": "./lib",
"rootDir": "./src", "rootDir": "./src",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": false, "noImplicitAny": false,
"resolveJsonModule": true, "resolveJsonModule": true,
"useUnknownInCatchVariables": false, "useUnknownInCatchVariables": false,
}, },
"exclude": [ "exclude": [
"./__mocks__/**/*",
"./__tests__/**/*",
"./lib/**/*",
"node_modules", "node_modules",
"**/*.test.ts",
"jest.config.ts" "jest.config.ts"
] ]
} }

3231
yarn.lock

File diff suppressed because it is too large Load Diff