Expressions in Docker URI

I’m trying to pass an ${{ expression }} inside a Docker URI in my workflow, as such:

**# ./github/workflows/main.yml**  

steps:
...
   - name: launch api
     uses: 'docker://${{ steps.previous_step.outputs.image }}'

Result is the error:

Unrecognized named-value: 'steps'.

As an alternative, I’ve tried:

**# ./github/workflows/main.yml**

steps:
   ...
   - name: launch api
     uses: ./.github/actions/forward-tags/
with:
image: ${{ steps.previous_step.outputs.image }

**# ./github/actions/forward-tags/action.yml** name: 'Forward tags'
inputs:
  image:
    required: true
runs:
  using: 'docker'
  image: 'docker://${{ inputs.image }}'

Result is the error:

Unrecognized named-value: 'inputs'.

Has anyone succesfully used expressions this way?

Thanks!

2 Likes

I was able to run it using:

steps:
...
   - name: launch api
     uses: actions/docker/cli@master
     with:
       args: 'run ${{ steps.previous_step.outputs.image }}'

However, it would be great to support uses: ‘docker://${{ steps.previous_step.outputs.image }}’ directly and be able to set Docker environment variables as properties of this step, etc.

1 Like

I had this exact problem without finding a solution. I will try the workaround but I would still like to know if this is a deliberate design decision, and the reasons in that case.

1 Like

Actually my use case is the proposed workaround from the OP: having the action take a parameter which is the dockerhub image name.

We currently do not support expressions in the uses tag in order to to know which repos we need to pull down as we are processing the job.  We also have a feature that limits the usage of third party actions and if actions are defined as an expression we would not be able to block that before the job starts on the runner.

Hello @chrispat , thanks for the clarification.

In my use case the action is statically given and the expression is in the image: parameter of runs:, entirely within the action. So perhaps this is a different issue to the restrictions you explain in your reply?

Lack of support for expressions in the “uses” tag imposes quite an inconvenience for docker-based actions.  Would it be possible to specify a path to a Dockerfile using an expression in the with stanza?

2 Likes

I also would like to be able to use the

name: 'Forward tags'
inputs:
  image:
    required: true
runs:
  using: 'docker'
  image: 'docker://${{ inputs.image }}'

syntax.

1 Like