How to run a GitHub Action Workflow conditionally Based on the Success or Non-Trigger of Another Workflow?

79 views Asked by At

I'm working on a GitHub repository with two distinct workflows, let's call them Workflow A and Workflow B. I am trying to achieve the following behavior:

When both Workflow A and B are triggered together: Workflow A should run first, and then Workflow B.

When only Workflow A is triggered: Workflow B doesn't necessarily have to run

When only Workflow B is triggered: Workflow B should run even if Workflow A is not triggered.

Current Setup:

name: A

on:
  push:
    branches: [main]
    paths:
      - "java/src/test/**/*"
  workflow_dispatch:
name: B

on:
  push:
    branches: [main]
    paths:
      - "java/src/main/**/*"
  workflow_run:
    workflows: ["A"]
    types:
      - completed
  workflow_dispatch:

How can I configure my GitHub Actions to meet these conditions?

0

There are 0 answers