okaryo.log

How to Fix the `Can't find action.yml, action.yaml, or Dockerfile` Error When Using Reusable Workflows in GitHubActions | okaryo.log

How to Fix the `Can't find action.yml, action.yaml, or Dockerfile` Error When Using Reusable Workflows in GitHubActions

    #GitHubActions#GitHub#CI/CD

Introduction

The other day, when I tried to use a Reusable Workflow in GitHub Actions, I encountered the following error.

Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/my-project/my-project/.github/workflows/some-action.yml'. Did you forget to run actions/checkout before running your local action?

While the cause wasn’t significant, I realized that my understanding of the syntax was incomplete, so I’m documenting it here.

Problematic Workflow

Here was my workflow:

jobs:
  ...some jobs...

  notify:
    needs: deploy
    runs-on: ubuntu-latest
    steps:
      - uses: ./.github/workflows/notify.yml

When I ran this, the above error occurred. Since the error message suggested, Did you forget to run actions/checkout before running your local action?, I decided to add actions/checkout as follows.

jobs:
  ...some jobs...

  notify:
    needs: deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/workflows/notify.yml

However, the same error persisted, and the workflow failed.

Solution

The reason for the error was that a Reusable Workflow must be called directly within the job, not inside step. The correct syntax is to call the Reusable Workflow using jobs.<job_id>.uses.

You can check the official documentation here:

Here’s the corrected workflow:

jobs:
  ...some jobs...

  notify:
    needs: deploy
    uses: ./.github/workflows/notify.yml

With this fix, the workflow executed successfully.

Conclusion

This error message likely assumes a misconfiguration with a Composite Action. For this reason, it wasn’t immediately clear how to resolve the issue just by reading the error.

I’ll make sure to fully understand the syntax before setting up workflows in the future.


Related Posts
Related Posts
Promotion

This site uses Google Analytics.