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 args #557

Closed
shyam-ks opened this issue Feb 2, 2022 · 7 comments
Closed

Build args #557

shyam-ks opened this issue Feb 2, 2022 · 7 comments

Comments

@shyam-ks
Copy link

shyam-ks commented Feb 2, 2022

I am trying to setup docker build in Github actions

- name: build-1
        run: |
          docker build . --build-arg JFROG_USERNAME=${{ secrets.JFROG_CREDS_USR }} --build-arg JFROG_PWD=${{ secrets.JFROG_CREDS_PSW }} 

      - name: build-2
        uses: docker/build-push-action@v2
        with:
          context: .
          file: ./Dockerfile
          push: false
          build-args: JFROG_USERNAME=${{ secrets.JFROG_CREDS_USR }},JFROG_PWD=${{ secrets.JFROG_CREDS_PSW }}

I have two args inside Dockerfile

ARG JFROG_PWD
ARG JFROG_USERNAME

Behaviour

In Dockerfile the command is = value="${JFROG_USERNAME}"

The first one (build-1) builds successfully, the Second one fails because the whole build args value is going to a single variable. like below
value=",JFROG_PWD="

Expected behavior - value="***"

I'm not able to figure out why the 2 build args are not setting values to their respective args inside Dockerfile when I am using docker/build-push-action@v2

@makoncline
Copy link

I think you should write it like this.

build-args: |
    JFROG_USERNAME=${{ secrets.JFROG_CREDS_USR }}
    JFROG_PWD=${{ secrets.JFROG_CREDS_PSW }}

@shyam-ks
Copy link
Author

shyam-ks commented Feb 8, 2022

I think you should write it like this.

build-args: |
    JFROG_USERNAME=${{ secrets.JFROG_CREDS_USR }}
    JFROG_PWD=${{ secrets.JFROG_CREDS_PSW }}

That worked. Thanks

@ckingbailey
Copy link

Would be nice if this was documented. There are no examples at the examples link, and the documentation says it's a "List", which I interpreted to mean a YAML list, like

build-args:
  - foo=bar
  - baz=yaz

or

build-args: [ 'foo=bar', 'baz=yaz' ]

which GitHub Actions language server in VSCode tells me is not valid input. (I'm guessing only strings, numbers, and booleans are valid arguments to an action? You learn something new...)

For reference, an example of an action that does document list-like syntax like this is actions/upload-artifact.

kingdonb pushed a commit to kingdonb/taking-bartholo that referenced this issue Mar 3, 2023
@aharpervc
Copy link

Would be nice if this was documented

I agree, I just found this discussion by searching for build args, since the readme offered no clarity and I assumed someone else had already complained 😁

@ibrahima
Copy link

ibrahima commented Apr 6, 2023

Ah, I was going to submit a PR for an example, but I realized it is actually documented at the top of the parameters section: https://github.com/docker/build-push-action#customizing

@besmirzanaj
Copy link

Ah, I was going to submit a PR for an example, but I realized it is actually documented at the top of the parameters section: https://github.com/docker/build-push-action#customizing

again this is not a YAML list, so the definition of the doc should be changed/updated

hasechris added a commit to hasechris/udp-broadcast-relay that referenced this issue Dec 15, 2023
NeonDaniel added a commit to NeonGeckoCom/.github that referenced this issue Dec 21, 2023
NeonDaniel added a commit to NeonGeckoCom/.github that referenced this issue Dec 21, 2023
* Update GHA versions to latest releases
Add optional `dockerfile` input for non-default dockerfiles
Add optional `build_args` input to support Docker build-args
Add caching to Docker builds

* Use separate input for extra build_args

* Update build_args handling per docker/build-push-action#557

---------

Co-authored-by: Daniel McKnight <[email protected]>
wtdcode added a commit to wtdcode/qemu-full that referenced this issue Dec 26, 2023
@xinatcg
Copy link

xinatcg commented Jun 17, 2024

Would be nice if this was documented. There are no examples at the examples link, and the documentation says it's a "List", which I interpreted to mean a YAML list, like

build-args:
  - foo=bar
  - baz=yaz

or

build-args: [ 'foo=bar', 'baz=yaz' ]

which GitHub Actions language server in VSCode tells me is not valid input. (I'm guessing only strings, numbers, and booleans are valid arguments to an action? You learn something new...)

For reference, an example of an action that does document list-like syntax like this is actions/upload-artifact.

Hope there example can be in the doc, it is easy to make mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants