Search code examples
githubgithub-actionsgithub-for-windowscicd

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


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


Solution

  • 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.