Github Actions Unable To See Dockerfile

Hi, I modified a Github actions file which is supposed to rename a file and then build a docker container from it, like this:

  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Rename the Dockerfile
      run: mv Dockerfile.js Dockerfile
    - uses: actions/checkout@v2
    - name: Build the Docker image
      run: docker build . --file Dockerfile --tag project
    - uses: actions/checkout@v1

However, whenever I run it, It always fails at the “Build the Docker image” because Github Actions says it does not exist even though it was successfully renamed.

The logfile: https://pastebin.com/raw/0SZ9V8bs

What is the issue?

The issue is that you do checkouts between your steps, which resets the directory to the state of your git repository. Usually you need to do checkout exactly once, at the start of your job. So try this:

  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Rename the Dockerfile
      run: mv Dockerfile.js Dockerfile
    - name: Build the Docker image
      run: docker build . --file Dockerfile --tag project
2 Likes