Using inputs when specifying Dockerfile name in the custom Docker action

Is it possible to use inputs when specifying the image name in the custom Docker action?

Something like:

runs:
  using: 'docker'
  image: 'Dockerfile-${{ inputs.php}}'
  args:
    - ${{ inputs.php}}

I’ve read that it’s not possible to use them in the uses part:

https://github.community/t5/GitHub-Actions/Expressions-in-Docker-URI/m-p/34067#M1778

But this is using them in the image name part. That way I could have multiple Dockerfiles in my repo, for instance for different PHP and Node.js versions, so that I don’t need to create N number of repos for my custom actions.

Hi @dingo-d ,

Currently it’s not supported to use inputs to specify docker image name.

As an alternative, in your action repository, you can create some subfolders to store your different actions. structure as below:

repo
  - action-a
      - Dockerfile
      - action.yaml
      - entrypoint.sh
  - action-b
      - Dockerfile
      - action.yaml
      - entrypoint.sh

And specify folder name of your action in workflow yaml file.

actions.png

Thanks.

1 Like

EDIT: Oh in my custom actions I can create multiple directories to store different dockers and then when I call my action those will be executed automatically! Will try that, thanks!

How do I specify the folder of the action in my workflow file?

Hi @dingo-d ,

In the workflow file, you need to add folder after your repo, for my action:

- name: use action
        uses: weide-zhou/hello-github-actions/<font color="#FF0000">action-a</font>@master
        with:
          who-to-greet: wadeaction1
      - uses: weide-zhou/hello-github-actions/<font color="#FF0000">action-b</font>@master
        with:
          who-to-greet: wadeaction2

My workflow here: https://github.com/weide-zhou/ticket13/runs/695896509?check_suite_focus=true

Thanks.

1 Like

That di the trick! Thanks!