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

build_extra_args json syntax does not handle multiple args #95

Closed
MaximeMYCS opened this issue Mar 24, 2021 · 2 comments · Fixed by #110
Closed

build_extra_args json syntax does not handle multiple args #95

MaximeMYCS opened this issue Mar 24, 2021 · 2 comments · Fixed by #110
Labels
bug Something isn't working good first issue Good for newcomers Hacktoberfest

Comments

@MaximeMYCS
Copy link

Using this Dockerfile:

FROM ubuntu:20.04 as test_image
ARG BRANCH
ARG ENV_NAME
RUN echo "${BRANCH}"
RUN echo "${ENV_NAME}"

And this workflow:


name: Test
on:
  push:
    paths:
    - ".github/workflows/test.yml"
    - "build/Dockerfile"

jobs:
  build-test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build test image
        uses: whoan/docker-build-with-cache-action@v5
        with:
          image_name: test_image
          build_extra_args: '{"--build-arg": "BRANCH=foo", "--build-arg": "ENV_NAME=haha"}'
          dockerfile: build/Dockerfile
          push_image_and_stages: false

It seems that the build arguments are not passed correctly: only the last one is kept. Below is the docker command line issued from the run of this workflow.

docker build --tag my_awesome_image --file ./build/Dockerfile --build-arg ENV_NAME=haha .

Is it because of a wrong syntax in the json description of arguments ? It seems to be working fine for a single argument but I haven't been able to make it work for more than one.

Thanks for your help.

@jschmidtnj
Copy link

I wrote something to fix the issue (see jschmidtnj@562d9b5). It's sort of a hack, but I couldn't figure out a way to get jq to accept duplicate keys (see jqlang/jq#1636). to use it, just append -0, or a dash followed by any unique number, to the end of a duplicated flag. for 2 build-args, it would be --build-arg-0 and --build-arg-1, etc.

@AndreuJove
Copy link

Hi guys I'm facing the same error, Do we have any update on this?

  • INPUT:

image

  • OUTPUT:

image


Using --build-arg-0 is not either working:

  • INPUT:

image

  • OUTPUT:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants