Search code examples
githubgithub-actionsgithub-actions-workflows

Github actions suddenly throwing "no version specified" for reusable workflows that worked yesterday


I'm not sure if this is a bug or a breaking change happened as of yesterday, I have a pretty simple setup calling three reusable workflows:

name: pr-checks

on:
  pull_request:
    branches: "**"

jobs:
  lint:
    name: Call Lint
    uses: ./.github/checks/check-lint.yaml

  test:
    name: Call Test
    uses: ./.github/checks/check-test.yaml

  e2e:
    name: Call E2E
    uses: ./.github/checks/check-e2e.yaml

But this throws

"invalid value workflow reference: no version specified"

as of now, even though identical workflows have worked yesterday.

When reusing workflows like this at the 'job' level - it is not necessary to specify version, in fact, it used to error out if I specified the version.

Screenshots attached as I think this doesn't make much sense.

enter image description here

I did click on 're-run all jobs and it re-ran successfully.

However, without any discenrable difference and after also removing the build step just to be sure there's nothing weird happening there:

enter image description here


Solution

  • As you can see in your 2 screenshots, one is referring to the .github/workflows directory (the one which worked), and the other to the .github/checks directory (the one which didn't).

    Short answer: If you change the workflow folder back to workflows instead of checks, it should work as expected.


    Long answer: It seems there is a confusion between the syntax of two different concepts:

    LOCAL ACTIONS

    To access local actions (folders with action.yml file) from your workflow, you need to use the actions/checkout first, to allow it to access the other repository folders and files.

    Example:

        steps:
          - uses: actions/checkout@v3 # Necessary to access local action
          - name: Local Action Call
            uses: ./.github/actions/local-action #path/to/action
    

    I've made a POC here some time ago if you want to have a look.

    REUSABLE WORKFLOWS

    Now, if you want to use reusable workflows, the issue is different:

    As with other workflow files, you locate reusable workflows in the .github/workflows directory of a repository. Subdirectories of the workflows directory are not supported.

    GitHub documentation reference

    In that case, according to this other section from the documentation:

    You reference reusable workflow files using one of the following syntaxes:

    {owner}/{repo}/.github/workflows/{filename}@{ref} for reusable workflows in public repositories.

    ./.github/workflows/{filename} for reusable workflows in the same repository.

    {ref} can be a SHA, a release tag, or a branch name.

    Example:

      lint:
        name: Call Lint
        uses: ./.github/workflows/check-lint.yaml@{SHA/TAG/BRANCH}
    

    or

      lint:
        name: Call Lint
        uses: ./.github/workflows/check-lint.yaml
    

    Here is another POC for the workflow call using this reusable workflow


    CONCLUSION

    It's like you were trying to call a reusable workflow as if it was a local action, which won't work as reusable workflows need to be located in the .github/workflows directory.

    Note that you could eventually add the @branch-name at the end of the workflow call to be sure to use the workflow from the branch you want to test if the reusable workflow is already present on the default branch.