Skip to content

Commit db66d4d

Browse files
authored
Inject DOCKER_META_IMAGES and DOCKER_META_VERSION args in bake definition (#37)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent b500d9c commit db66d4d

4 files changed

Lines changed: 44 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ jobs:
159159
### Bake definition
160160

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

165165
```hcl
166166
// docker-bake.hcl
@@ -240,6 +240,10 @@ Content of `${{ steps.docker_meta.outputs.bake-file }}` file will look like this
240240
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
241241
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
242242
"org.opencontainers.image.licenses": "MIT"
243+
},
244+
"args": {
245+
"DOCKER_META_IMAGES": "name/app",
246+
"DOCKER_META_VERSION": "1.1.1"
243247
}
244248
}
245249
}

__tests__/meta.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,10 @@ describe('bake-file', () => {
15121512
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
15131513
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
15141514
"org.opencontainers.image.licenses": "MIT"
1515+
},
1516+
"args": {
1517+
"DOCKER_META_IMAGES": "user/app",
1518+
"DOCKER_META_VERSION": "dev",
15151519
}
15161520
}
15171521
}
@@ -1539,6 +1543,10 @@ describe('bake-file', () => {
15391543
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
15401544
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
15411545
"org.opencontainers.image.licenses": "MIT"
1546+
},
1547+
"args": {
1548+
"DOCKER_META_IMAGES": "user/app",
1549+
"DOCKER_META_VERSION": "dev",
15421550
}
15431551
}
15441552
}
@@ -1569,6 +1577,10 @@ describe('bake-file', () => {
15691577
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
15701578
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
15711579
"org.opencontainers.image.licenses": "MIT"
1580+
},
1581+
"args": {
1582+
"DOCKER_META_IMAGES": "user/app",
1583+
"DOCKER_META_VERSION": "release1",
15721584
}
15731585
}
15741586
}
@@ -1600,6 +1612,10 @@ describe('bake-file', () => {
16001612
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
16011613
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
16021614
"org.opencontainers.image.licenses": "MIT"
1615+
},
1616+
"args": {
1617+
"DOCKER_META_IMAGES": "user/app",
1618+
"DOCKER_META_VERSION": "20200110",
16031619
}
16041620
}
16051621
}
@@ -1640,6 +1656,10 @@ describe('bake-file', () => {
16401656
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
16411657
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
16421658
"org.opencontainers.image.licenses": "MIT"
1659+
},
1660+
"args": {
1661+
"DOCKER_META_IMAGES": "org/app,ghcr.io/user/app",
1662+
"DOCKER_META_VERSION": "1.1.1",
16431663
}
16441664
}
16451665
}
@@ -1673,6 +1693,10 @@ describe('bake-file', () => {
16731693
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
16741694
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
16751695
"org.opencontainers.image.licenses": "MIT"
1696+
},
1697+
"args": {
1698+
"DOCKER_META_IMAGES": "org/app,ghcr.io/user/app",
1699+
"DOCKER_META_VERSION": "my",
16761700
}
16771701
}
16781702
}
@@ -1707,6 +1731,10 @@ describe('bake-file', () => {
17071731
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
17081732
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
17091733
"org.opencontainers.image.licenses": "MIT"
1734+
},
1735+
"args": {
1736+
"DOCKER_META_IMAGES": "org/app",
1737+
"DOCKER_META_VERSION": "v1.1.1",
17101738
}
17111739
}
17121740
}

dist/index.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/meta.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ export class Meta {
164164
target: {
165165
'ghaction-docker-meta': {
166166
tags: this.tags(),
167-
labels: jsonLabels
167+
labels: jsonLabels,
168+
args: {
169+
DOCKER_META_IMAGES: this.inputs.images.join(','),
170+
DOCKER_META_VERSION: this.version.main
171+
}
168172
}
169173
}
170174
},

0 commit comments

Comments
 (0)