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

Release 4.1.0: Using a variable with hashtag breaks the docker build command #879

Closed
gastonfournier opened this issue Jun 12, 2023 · 3 comments · Fixed by #880
Closed

Release 4.1.0: Using a variable with hashtag breaks the docker build command #879

gastonfournier opened this issue Jun 12, 2023 · 3 comments · Fixed by #880
Labels
kind/bug Something isn't working

Comments

@gastonfournier
Copy link

Behaviour

After the latest release v4.1.0 there's an issue when using build args containing a hashtag # where everything after the hashtag is trimmed out (I believe it's being treated as a comment). In version 4.0.0 it works as expected (see this example run from main with the version 4.0.0 pinned)

Steps to reproduce this issue

  1. Run this workflow from the branch named bug
  2. Check the output (example: https://github.com/gastonfournier/build-args-test/actions/runs/5243868766/jobs/9469101934#step:6:113)

Expected behaviour

The variable BUILD_ARG_PARAM should be passed on as is to --build-arg

/usr/bin/docker buildx build --build-arg NPM_TOKEN=HELLO_WORLD --build-arg BUILD_ARG_PARAM=pre-hashtag#post-hashtag --file Dockerfile --iidfile /tmp/docker-actions-toolkit-MqCSOI/iidfile --platform linux/arm64 --provenance mode=max,builder-id=https://github.com/gastonfournier/build-args-test/actions/runs/5243868766 --metadata-file /tmp/docker-actions-toolkit-MqCSOI/metadata-file .

Actual behaviour

The variable BUILD_ARG_PARAM is trimmed from the hastag #

/usr/bin/docker buildx build --build-arg NPM_TOKEN=HELLO_WORLD --build-arg BUILD_ARG_PARAM=pre-hashtag --file Dockerfile --iidfile /tmp/docker-actions-toolkit-MqCSOI/iidfile --platform linux/arm64 --provenance mode=max,builder-id=https://github.com/gastonfournier/build-args-test/actions/runs/5243868766 --metadata-file /tmp/docker-actions-toolkit-MqCSOI/metadata-file .

Configuration

name: Continuous integration and deployment
on:
  workflow_dispatch:

jobs:
  build:
    env:
      BUILD_ARG_PARAM: undefined
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: docker/setup-qemu-action@v2
      - uses: docker/setup-buildx-action@v2
      - run: echo BUILD_ARG_PARAM=pre-hashtag#post-hashtag >> $GITHUB_ENV
      - uses: docker/build-push-action@v4
        with:
          context: .
          file: Dockerfile
          platforms: linux/arm64
          push: false
          build-args: |
            NPM_TOKEN=HELLO_WORLD
            BUILD_ARG_PARAM=${{ env.BUILD_ARG_PARAM }}

Logs

@crazy-max
Copy link
Member

This looks related to docker/bake-action#141 😥

Not related but in your case you don't need to pass the value but just set the key of the build arg:

      - uses: docker/build-push-action@v4
        with:
          context: .
          file: Dockerfile
          platforms: linux/arm64
          push: false
          build-args: |
            NPM_TOKEN=HELLO_WORLD
            BUILD_ARG_PARAM

@crazy-max crazy-max added the kind/bug Something isn't working label Jun 12, 2023
@gastonfournier gastonfournier changed the title Using a variable with hashtag breaks the docker build command Release 4.1.0: Using a variable with hashtag breaks the docker build command Jun 12, 2023
@crazy-max
Copy link
Member

crazy-max commented Jun 12, 2023

@gastonfournier
Copy link
Author

This looks related to docker/bake-action#141 disappointed_relieved

Not related but in your case you don't need to pass the value but just set the key of the build arg:

      - uses: docker/build-push-action@v4
        with:
          context: .
          file: Dockerfile
          platforms: linux/arm64
          push: false
          build-args: |
            NPM_TOKEN=HELLO_WORLD
            BUILD_ARG_PARAM

Yes, seems related. I'm going over your comments. For now pinning to v.4.0.0 helped us get unblocked but I'm more than happy to test some stuff to help with this ;)

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