Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use multiple names when using output type=image #1072

Closed
alessfg opened this issue Mar 5, 2024 · 4 comments · Fixed by #1074
Closed

Ability to use multiple names when using output type=image #1072

alessfg opened this issue Mar 5, 2024 · 4 comments · Fixed by #1074
Labels
kind/bug Something isn't working

Comments

@alessfg
Copy link

alessfg commented Mar 5, 2024

Description

Hello! Not entirely sure if this is a bug or a missing functionality, but tl;dr -- I can't seem to figure out how to use multiple names when using output type=image and thus push the image to multiple registries (you can find the original PR here nginxinc/docker-nginx-unprivileged#195). The docs mention that when using the buildx CLI, you can wrap the list of names in double quotes, but no matter what I try, this action seems to fail. I've tested all combinations of escape sequences too to no avail ("",\",\\"). I've also opened up a discussion which includes a bit more information (#1067). Finally, here's a sample code block of one of the things I've tried:

- name: Build and push image to Docker Hub and GitHub Container Registry
  id: build
  uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
  with:
    platforms: ${{ matrix.platform }}
    context: "."
    labels: ${{ steps.meta.outputs.labels }}
    outputs: type=image,name=\"ghcr.io/nginxinc/nginx-unprivileged,docker.io/nginxinc/nginx-unprivileged\",push-by-digest=true,name-canonical=true,push=true

Let me know if you need any more information!

@alessfg alessfg added kind/enhancement New feature or request status/triage labels Mar 5, 2024
@alessfg alessfg changed the title Ability to use multiple names when using output type=image Ability to use multiple names when using output type=image Mar 5, 2024
@crazy-max
Copy link
Member

I repro as well with:

image

Do you have the same error?

@alessfg
Copy link
Author

alessfg commented Mar 5, 2024

Yep! That's one of the errors I'm seeing. The actual error depends on the "format" I try but they all follow the same style.

@crazy-max
Copy link
Member

crazy-max commented Mar 6, 2024

Ok so this error #1072 (comment) is related to csv parsing in build command (buildx) which make sense because quotes should take the whole column. Correct syntax is:

type=image,"name=ghcr.io/nginxinc/nginx-unprivileged,docker.io/nginxinc/nginx-unprivileged",push-by-digest=true,name-canonical=true,push=true

But still fails with:

Error: buildx failed with: ERROR: invalid value docker.io/nginxinc/nginx-unprivileged

I think this is related to the csv-parse lib that we are using in our actions toolkit: https://github.com/docker/actions-toolkit/blob/7fb507050a318dff09c0e4dd89c14a569fc62548/src/util.ts#L40 that is stripping the quotes where it should not:

/usr/bin/docker buildx build --file ./Dockerfile --iidfile /home/runner/work/_temp/docker-actions-toolkit-8En3Bu/iidfile --output type=image,name=ghcr.io/nginxinc/nginx-unprivileged,docker.io/nginxinc/nginx-unprivileged,push-by-digest=true,name-canonical=true,push=true ...

So might need changes in actions-toolkit. Still digging.

@crazy-max
Copy link
Member

Ok after tests in docker/actions-toolkit#273, we need to keep quotes around fields for this input by setting quote to false: https://csv.js.org/parse/options/quote/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants