I have got two workflows:
I need in workflow2.yaml add something like:
jobs:
build_kotlin:
runs-on: [server1, server2, server3]
needs: [workflow1]
steps:
- name: Checkout code
uses: actions/checkout@v2
Currently "needs" doesn't work properly. How can reference separate workflow yaml file?
needs is only used to establish relationships between jobs -- not entire workflows.
If you want to run "workflow2.yaml" after "workflow1.yaml" has been completed, then add a trigger like so:
on:
workflow_run:
workflows: [workflow1]
types:
- completed
jobs:
build_kotlin
# ...
Read more on Events That Trigger Workflows
Alternatively, you could make workflow1 a reusable workflow and then make sure it is executed before workflow2 like so:
jobs:
workflow1:
uses: octo-org/example-repo/.github/workflows/workflow1.yaml@main
build_kotlin:
runs-on: [server1, server2, server3]
needs: [workflow1]
steps:
- name: Checkout code
uses: actions/checkout@v2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With