0

I have one file build.yml which have jobs, steps for a react app deployment. I have another workflow file issue.yml which is responsible for creating an issue if any steps gets failed in build.yml.

I would like to trigger workflow file issue.yml only when workflow file build.yml have an issue. I know, I can achieve it, if I created another step in workflow file build.yml to create an issue and use condition if failure().

Just wanted to check if anyone have idea to achieve it by using 2 different workflow files.

Error Hunter
  • 1,354
  • 3
  • 13
  • 35

1 Answers1

0

You could use a the workflow_run trigger in your issue.yml workflow:

If you inform to start it only when the informed workflow is completed (with success or failure) you will be able to do what you want doing something like this:

on:
  workflow_run:
    workflows: ["<build workflow name>"]
    types: [completed]

jobs:
  on-success:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    steps:
      ...
  on-failure:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'failure' }}
    steps:
      ...

You can find more information about this trigger on the Events that trigger workflows documenation.

GuiFalourd
  • 15,523
  • 8
  • 44
  • 71