Skip to content

Commit 2a4836a

Browse files
authored
Merge pull request #353 from crazy-max/split-bake-file
bake: split definition into two files
2 parents f3c3cad + 9bdb15d commit 2a4836a

File tree

8 files changed

+229
-67
lines changed

8 files changed

+229
-67
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ jobs:
323323
with:
324324
files: |
325325
./test/docker-bake.hcl
326-
${{ steps.docker_meta.outputs.bake-file }}
326+
${{ steps.docker_meta.outputs.bake-file-tags }}
327+
${{ steps.docker_meta.outputs.bake-file-labels }}
327328
targets: |
328329
release
329330

README.md

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ jobs:
230230
targets: build
231231
```
232232

233-
Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with
234-
`refs/tags/v1.2.3` ref:
233+
Content of `${{ steps.meta.outputs.bake-file }}` file, combining tags and
234+
labels, will look like this with `refs/tags/v1.2.3` ref:
235235

236236
```json
237237
{
@@ -262,6 +262,22 @@ Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with
262262
}
263263
```
264264

265+
You can also use the `bake-file-tags` and `bake-file-labels` outputs if you
266+
just want to use tags and/or labels respectively. The following example is
267+
similar to the previous one:
268+
269+
```yaml
270+
-
271+
name: Build
272+
uses: docker/bake-action@v3
273+
with:
274+
files: |
275+
./docker-bake.hcl
276+
${{ steps.meta.outputs.bake-file-tags }}
277+
${{ steps.meta.outputs.bake-file-labels }}
278+
targets: build
279+
```
280+
265281
## Customizing
266282

267283
### inputs
@@ -276,36 +292,38 @@ The following inputs can be used as `step.with` keys:
276292
> org.opencontainers.image.vendor=MyCompany
277293
> ```
278294

279-
| Name | Type | Description |
280-
|---------------------|--------|-------------------------------------------------------------------------------|
281-
| `context` | String | Where to get context data. Allowed options are: `workflow` (default), `git`. |
282-
| `images` | List | List of Docker images to use as base name for tags |
283-
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
284-
| `flavor` | List | [Flavor](#flavor-input) to apply |
285-
| `labels` | List | List of custom labels |
286-
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
287-
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
288-
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
295+
| Name | Type | Description |
296+
|---------------|--------|-------------------------------------------------------------------------------|
297+
| `context` | String | Where to get context data. Allowed options are: `workflow` (default), `git`. |
298+
| `images` | List | List of Docker images to use as base name for tags |
299+
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
300+
| `flavor` | List | [Flavor](#flavor-input) to apply |
301+
| `labels` | List | List of custom labels |
302+
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
303+
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
304+
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
289305

290306
### outputs
291307

292308
The following outputs are available:
293309

294-
| Name | Type | Description |
295-
|-------------|--------|----------------------------------------------------------------------------|
296-
| `version` | String | Docker image version |
297-
| `tags` | String | Docker tags |
298-
| `labels` | String | Docker labels |
299-
| `json` | String | JSON output of tags and labels |
300-
| `bake-file` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path |
310+
| Name | Type | Description |
311+
|--------------------|--------|-------------------------------------------------------------------------------------------------|
312+
| `version` | String | Docker image version |
313+
| `tags` | String | Docker tags |
314+
| `labels` | String | Docker labels |
315+
| `json` | String | JSON output of tags and labels |
316+
| `bake-file-tags` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with tags |
317+
| `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
301318

302319
Alternatively, each output is also exported as an environment variable:
303320

304321
* `DOCKER_METADATA_OUTPUT_VERSION`
305322
* `DOCKER_METADATA_OUTPUT_TAGS`
306323
* `DOCKER_METADATA_OUTPUT_LABELS`
307324
* `DOCKER_METADATA_OUTPUT_JSON`
308-
* `DOCKER_METADATA_OUTPUT_BAKE_FILE`
325+
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS`
326+
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_LABELS`
309327

310328
So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/):
311329

0 commit comments

Comments
 (0)