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

2

11

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

Schaab answered 1/3, 2022 at 16:36 Comment(0)
T
8

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.

Taxdeductible answered 3/3, 2022 at 20:28 Comment(1)
Cannot define both uses and steps at the same time for the following jobs: e2e-android-nativeSubmersed
G
4

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.

Galilee answered 9/9, 2022 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.