bake-action icon indicating copy to clipboard operation
bake-action copied to clipboard

Null value for `tags` when using with `docker/metadata-action` bake file output

Open tk-nguyen opened this issue 1 year ago • 0 comments

Contributing guidelines

I've found a bug, and:

  • [X] The documentation does not mention anything about my problem
  • [X] There are no open or closed issues that are related to my problem

Description

Hello! I'm using this action together with docker/metadata-action bake file output. I'm using the tags from docker-metadata-action target to generate image name.

Expected behaviour

It should build normally, using the tags from meta action.

Actual behaviour

The action errors out:

Error: #1 [internal] load local bake definitions
#1 reading ./docker-bake.hcl 320B / 320B done
#1 reading /home/runner/work/_temp/docker-actions-toolkit-ZPTkvi/docker-metadata-action-bake-tags.json 247B / 247B done
#1 reading /home/runner/work/_temp/docker-actions-toolkit-ZPTkvi/docker-metadata-action-bake-labels.json 643B / 643B done
#1 reading /home/runner/work/_temp/docker-actions-toolkit-ZPTkvi/docker-metadata-action-bake-annotations.json 696B / 696B done
#1 DONE 0.0s
./docker-bake.hcl:14
--------------------
  12 |     target "test" {
  13 |       inherits = ["_common"]
  14 | >>>   tags = generate_tags("docker.io", target.docker-metadata-action.tags)
  15 |     }
  16 |     
--------------------
ERROR: ./docker-bake.hcl:14,37-71: Invalid function argument; Invalid value for "tags" parameter: argument must not be null., and 1 other diagnostic(s)

Repository URL

https://github.com/tk-nguyen/docker-bake-demo (master branch is after when I moved the bake file with the tags last)

Workflow run URL

https://github.com/tk-nguyen/docker-bake-demo/actions/runs/8098999772/job/22133738961

YAML workflow

on:
  push:
    tags:
      - v*.*.*

name: Docker bake test

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          tags: |
            type=semver,pattern=v{{version}}
            type=semver,pattern=v{{major}}
            type=semver,pattern=v{{major}}.{{minor}}

      - name: Build and push
        uses: docker/bake-action@v4
        with:
          files: |
            ./docker-bake.hcl
            ${{ steps.meta.outputs.bake-file }}
            ${{ steps.meta.outputs.bake-file-annotations }}
          targets: test

Additional info

When I put the bake file with the tags last (either ${{ steps.meta.outputs.bake-file }} or ${{ steps.meta.outputs.bake-file-tags }}), it works perfectly, as seen here: https://github.com/tk-nguyen/docker-bake-demo/actions/runs/8099076031/job/22133989604

tk-nguyen avatar Feb 29 '24 16:02 tk-nguyen