Actions - Reusable workflow failing to find action.yml (that does exist)

I’m trying to use reusable workflows but Actions is failing to find the action.yml within the local repo:

Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/<reponame>/github_shared_workflows/build/action.yml'. Did you forget to run actions/checkout before running your local action?

However I do a ls in the same job I can see that it does exist:

Run ls -laR ./.github/workflows/
...

./.github/workflows/build:
total 16
drwxr-xr-x 2 runner docker 4096 Feb 23 00:07 .
drwxr-xr-x 4 runner docker 4096 Feb 23 00:07 ..
-rw-r--r-- 1 runner docker 6311 Feb 23 00:07 action.yml

./.github/workflows/deploy:
total 12
drwxr-xr-x 2 runner docker 4096 Feb 23 00:07 .
drwxr-xr-x 4 runner docker 4096 Feb 23 00:07 ..
-rw-r--r-- 1 runner docker 4022 Feb 23 00:07 action.yml

Job definition:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: ls -laR ./.github/workflows/
      - id: build
        uses: ./.github/workflows/build/action.yml

Any suggestions would be greatly appreciated!

1 Like

Hi there @sammcj - thanks for posting your query :heart: I’ve recategorized this so you’ll get better visibility among those who are best able to assist you!

This is something I’ve hit recently and cost me a few hours research to find a way forward.

The main reason reusable blocks fail is because they have been used in a “Steps” block. This is apparently not supported.

Reusable blocks, to be found and work, can only be the single element in a Job definition, e.g.:

works

jobs:
  validate-environment:
    uses: ./.github/workflows/getunityversionfrompackage.yml
    name: Get Unity Version from UPM package
    with:
      build-target: windows

If there are any other elements in the Job, the reusable workflow cannot be found and will fail

if however you put reusable blocks in steps, this simply will not work

Does NOT work

jobs:
   validate-environment:
    runs-on: ${{ inputs.build-target }}
    outputs:
      upmunityversion: ${{ steps.getVersion.outputs.upmunityversion }}
    steps:
      - uses: ./.github/workflows/getunityversionfrompackage.yml
         with:
             build-target: windows

My best advice is to put all your workloads into reusable blocks and simply have a master build yaml that just calls them in jobs.

Hope that helps

6 Likes

I’m facing same issue

I’ve detailed my tests including a public repository showing working and not working examples
Reusable yml in local repository cannot be found if executed in steps - Code to Cloud / GitHub Actions - GitHub Community

In short, you CANNOT use reusable blocks in a “Steps” group. They only work when they are the only action in a Job

2 Likes

If you’re trying to reuse your code inside the steps block you might want to convert this reusable workflow to a composite action instead:

They’re similar concepts but composite actions can be combined with other steps inside the steps block.

1 Like

Beware that some Azure DevOps → GitHub Actions converters will still inject the steps: block. That is what got me here. Luckily the Docs are correct, no steps: block:
Reusing workflows - GitHub Docs