Skip to content

Commit

Permalink
Inject DOCKER_META_IMAGES and DOCKER_META_VERSION args in bake defini…
Browse files Browse the repository at this point in the history
…tion (#37)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max and crazy-max authored Dec 24, 2020
1 parent b500d9c commit db66d4d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ jobs:
### Bake definition

This action also handles a bake definition file that can be used with the
[Docker Buildx Bake action](https://github.com/crazy-max/ghaction-docker-buildx-bake). You just have to declare a
target named `ghaction-docker-meta`.
[Docker Buildx Bake action](https://github.com/crazy-max/ghaction-docker-buildx-bake). You just have to declare an empty
target named `ghaction-docker-meta` and inherit from it.

```hcl
// docker-bake.hcl
Expand Down Expand Up @@ -240,6 +240,10 @@ Content of `${{ steps.docker_meta.outputs.bake-file }}` file will look like this
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "name/app",
"DOCKER_META_VERSION": "1.1.1"
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions __tests__/meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,10 @@ describe('bake-file', () => {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "user/app",
"DOCKER_META_VERSION": "dev",
}
}
}
Expand Down Expand Up @@ -1539,6 +1543,10 @@ describe('bake-file', () => {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "user/app",
"DOCKER_META_VERSION": "dev",
}
}
}
Expand Down Expand Up @@ -1569,6 +1577,10 @@ describe('bake-file', () => {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "user/app",
"DOCKER_META_VERSION": "release1",
}
}
}
Expand Down Expand Up @@ -1600,6 +1612,10 @@ describe('bake-file', () => {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "user/app",
"DOCKER_META_VERSION": "20200110",
}
}
}
Expand Down Expand Up @@ -1640,6 +1656,10 @@ describe('bake-file', () => {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "org/app,ghcr.io/user/app",
"DOCKER_META_VERSION": "1.1.1",
}
}
}
Expand Down Expand Up @@ -1673,6 +1693,10 @@ describe('bake-file', () => {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "org/app,ghcr.io/user/app",
"DOCKER_META_VERSION": "my",
}
}
}
Expand Down Expand Up @@ -1707,6 +1731,10 @@ describe('bake-file', () => {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
"DOCKER_META_IMAGES": "org/app",
"DOCKER_META_VERSION": "v1.1.1",
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ export class Meta {
target: {
'ghaction-docker-meta': {
tags: this.tags(),
labels: jsonLabels
labels: jsonLabels,
args: {
DOCKER_META_IMAGES: this.inputs.images.join(','),
DOCKER_META_VERSION: this.version.main
}
}
}
},
Expand Down

0 comments on commit db66d4d

Please sign in to comment.