9

reusable workflows should be referenced at the top-level `jobs.*.uses' key, not within steps

name: HelloWorld 
 on:
  workflow_dispatch:

 jobs:
  checkout:
   runs-on: windows-latest

  steps:
   - name: Checkout using the Template File 
     uses: actions/checkout@v2

   - name: Compile Java
     uses: org/repo/.github/workflows/build.yml@main
     with:
       jdk_version: 11
      
     

Error: .github#L1 reusable workflows should be referenced at the top-level `jobs.*.uses' key, not within steps

wehelpdox
  • 339
  • 6
  • 16

2 Answers2

6

Try the following:

name: HelloWorld 
 on:
  workflow_dispatch:

 jobs:
  checkout:
   uses: org/repo/.github/workflows/build.yml@main
   with:
    jdk_version: 11

And then at the beginning of build.yml, you can do

runs-on: windows-latest
steps:
 - uses: actions/checkout@v2

For whatever reason reusable workflows can't be inside steps, so you have to just use it at the top-level and do all your configuration/other steps inside the workflow you're calling.

Scott
  • 232
  • 1
  • 10
2

Workflows can't be nested. A workflow bundles a bunch of actions.

You have to convert your workflows/build.yml into an actions/build.yml and then that action can be used for individual steps.

sod
  • 3,804
  • 5
  • 22
  • 28