Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 6

Using inputs when specifying Dockerfile name in the custom Docker action

Solved! Go to Solution.

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.

5 Replies
Highlighted
GitHub Partner
Message 2 of 6

Re: Using inputs when specifying Dockerfile name in the custom Docker action

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.

Highlighted
Copilot Lvl 3
Message 3 of 6

Re: Using inputs when specifying Dockerfile name in the custom Docker action

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!

Highlighted
Copilot Lvl 3
Message 4 of 6

Re: Using inputs when specifying Dockerfile name in the custom Docker action

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

Highlighted
Solution
GitHub Partner
Message 5 of 6

Re: Using inputs when specifying Dockerfile name in the custom Docker action

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/action-a@master
        with:
          who-to-greet: wadeaction1
      - uses: weide-zhou/hello-github-actions/action-b@master
        with:
          who-to-greet: wadeaction2

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

 

Thanks.

Highlighted
Copilot Lvl 3
Message 6 of 6

Re: Using inputs when specifying Dockerfile name in the custom Docker action

That di the trick! Thanks!