Running correct Dockerfile

I have the following:

.github/actions/tests/action.yml

# action.yml
name: 'Run tests'
description: 'Run tests'
runs:
  using: 'docker'
  image: '../../../tests.Dockerfile'

.github/workflows/build.yml

- name: run tests
        id: tests
        uses: ./.github/actions/tests

I also have in my repo root both a Dockerfile and tests.Dockerfile

For some reason, the above action is running Dockerfile instead of tests.Dockerfile.

How can I fix it so that it runs tests.Dockerfile?

In Docker, Dockerfile can be renamed as ‘tests.Dockerfile’ but it doesn’t work in Github action. An internal ticket is created for tracking, thanks a lot for reaching this out! :slight_smile:

As an alternative, if you would like to use two Dockerfile, please put the new one in another folder, eg: tests/Dockerfile.

Structure like below:

Root
-Dockerfile
-action.yml
-entrypoint.sh
-tests
  -Dockerfile
  -entrypoint.sh

In workflow file, specify different action.yml directory for ‘uses’, code sample as below:

- name: Hello world action step1
uses: ./.github/actions/hello-world-action # Uses an action in the hello-world-action directory
with:
who-to-greet: 'xman1'
- name: Hello world action step2
uses: ./ # Uses an action in the root directory
with:
who-to-greet: 'xman2'
1 Like

Oh, good to know!

For my specific use case I ended up solving it via one multi-stage Dockerfile and build targets.

Also didn’t realize I could just call docker straight instead of writing an action :slight_smile:

But could to know this helped surface an improvement!

1 Like