Use inputs in Dockerfile property of Docker container action

I want to take the image: in a custom docker action from an input, something like:

    description: 'Base image'
    required: true
    default: 'docker://ubuntu:latest'
  using: 'docker'
  image: '${{ inputs.distro }}'
  entrypoint: './'

however this leads to the following error: “System.ArgumentException: Unexpected type ‘’ encountered while reading ‘action manifest root’. The type ‘MappingToken’ was expected.”

Any ideas? I saw 16846, but that approach doesn’t inherit the filesystem nor the environment.

In the metadata file (action.yml or action.yaml) of a Docker action, the expression ${{ inputs.<input_name> }} is used to pass the inputs to the container’s ENTRYPOINT when the container starts up. We can’t use this expression to pass the value of an input to other options in the metadata file.

The value of runs.image can be the Docker base image name, a local Dockerfile in your repository, or a public image in Docker Hub or another registry. And we seem need to provide an explicit value directly, instead of referencing a variable.

Got it, is there another way to set the base image based on user input? I could see a hackish way by editing the Dockerfile before handing it over.


  1. When using a Docker action via the syntax "uses: <actionOrg>/<actionRepo>@<ref>"in a job, before actually running all the steps you setup in the job, the “docker build” is following after the “Set up job”. In the automatically generated “docker build” step, it will checkout the source code of the Docker action to the runner’s working directory, then build the Docker container according to the configurations you set in the Dockerfile.
    So in this way, using a step to change the Dockerfile before the Docker action executes is not effective in the job.

  2. However, as a workaround, you can try the below steps to execute the Docker action, instead of using the syntax “uses: <actionOrg>/<actionRepo>@<ref>”.
    For example:

  - name: Checkout source code of the docker action
    uses: actions/checkout@v2
      repository: actionOrg/actionRepo
      ref: <branch, tag or SHA>
      token: ${{ secrets.GITHUB_PAT }}  # when checkout from another repository, you need to create a personal access token to authenticate
      path: actions/actionOrg/actionRepo

  - name: Change the settings in 'Dockerfile' or 'action.yml'
    . . .

  - name: Run the docker action
    uses: ./actions/actionOrg/actionRepo

In this way, the “docker build” is executed at the beginning of the action step “Run the docker action”. Before this step, you need to checkout the source code of the docker action, then you can change the ‘Dockerfile’ or ‘action.yml’ as you like.