Skip to content

Commit

Permalink
bake: split definition into two files
Browse files Browse the repository at this point in the history
Allows to either include tags or labels or both definitions.
Keep bake-file output for backward compatiblity.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Nov 16, 2023
1 parent 62339db commit dd060cb
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ jobs:
with:
files: |
./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: |
release
Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,13 @@ jobs:
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
${{ steps.meta.outputs.bake-file-tags }}
${{ steps.meta.outputs.bake-file-labels }}
targets: build
```

Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with
`refs/tags/v1.2.3` ref:
Content of `${{ steps.meta.outputs.bake-file-tags }}` and `${{ steps.meta.outputs.bake-file-labels }}`
files merged will look like this with `refs/tags/v1.2.3` ref:

```json
{
Expand Down Expand Up @@ -291,21 +292,23 @@ The following inputs can be used as `step.with` keys:

The following outputs are available:

| Name | Type | Description |
|-------------|--------|----------------------------------------------------------------------------|
| `version` | String | Docker image version |
| `tags` | String | Docker tags |
| `labels` | String | Docker labels |
| `json` | String | JSON output of tags and labels |
| `bake-file` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path |
| Name | Type | Description |
|--------------------|--------|----------------------------------------------------------------------------------------|
| `version` | String | Docker image version |
| `tags` | String | Docker tags |
| `labels` | String | Docker labels |
| `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 |

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_JSON`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_LABELS`

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

Expand Down
17 changes: 17 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Upgrade notes

## v5 to v6

Bake definition has been split into two files, so you can include either tags
or labels or both:

```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
```
## v2 to v3
* Repository has been moved to docker org. Replace `crazy-max/ghaction-docker-meta@v2`
Expand Down
Loading

0 comments on commit dd060cb

Please sign in to comment.