3

I have got two workflows:

  • workflow1.yaml
  • workflow2.yaml

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?

1 Answer 1

9

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.