docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.28k stars 548 forks source link

feat: Support List and CSV for the `labels` input #873

Closed hegerdes closed 1 year ago

hegerdes commented 1 year ago

For setting multiple labels to the actions input you need a setup like this:

      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          push: true
          tags: user/app:latest
         labels: |
           Foo=Bar
           Bar=Baz

but this can not be archived when using ${{ inputs.labels }} in GH Action when it is a reusable workflow or a manuell one. The CSV variant also does not work because ignore commas in https://github.com/docker/build-push-action/blob/a799b4decf46d51b39dd396f4df5a4343afd30c4/src/context.ts#L55 is set to true

      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          push: true
          tags: user/app:latest
          labels: ${{ inputs.build-labels }}

This is needed because GH Action inputs only allow the types string, choice and bolean but not objects or arrays

Consider allowing CSV input to allow for reusable/composite and manuell workflow usage

crazy-max commented 1 year ago

We can't use CSV type for labels as you've seen in #874. For your case consider adding an extra step like https://github.com/docker/metadata-action/issues/298#issuecomment-15874439780.