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.11k stars 527 forks source link

output doesn't allow interpolation/accessing environment variables #986

Closed BPodszun closed 8 months ago

BPodszun commented 9 months ago

Contributing guidelines

I've found a bug, and:

Description

The 'outputs' doesn't seem to accept any dynamic expression, neither normal environment variables ($foo) nor Github Action expressions (${{ env.foo}})

Expected behaviour

I would expect that either $foo or ${{ env.foo }} works in outputs and evaluates to the environment variable's value at runtime.

Actual behaviour

The action creates a file that is literally called '$foo' or '${{ env.foo }}' in the filesystem.

Repository URL

No response

Workflow run URL

No response

YAML workflow

- name: Build the Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        push: false
        tags: somethingHere
        outputs: type=docker,dest=/tmp/{{ env.BuildArtifact }}.tar
        build-args: |
          GitVersion=$(git describe --all --long)
          GitHash=$(git rev-parse HEAD)
          BuildTime="$(date -u -Ins)"


### Workflow logs

_No response_

### BuildKit logs

_No response_

### Additional info

_No response_
crazy-max commented 8 months ago

GitHub Actions inputs don't execute shell commands. You need to add a run step right before the Build the Docker image one and use the output values in build-args: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter