Workflow_run completed event triggered by failed workflow

I have a workflow triggered as follows:

name: Production deploy
on:
  workflow_run:
    workflows: ["Stage deploy"]
    types:
      - completed

I expect that after the stage deploy (which also runs API tests) completes successfully, then the production deploy would start. However, I just watched a failed stage deploy (which skipped its API tests due to the failed deploy) also trigger a production deploy. Is there a different “types” value for workflow_run that causes it not to fire if the workflow failed, rather than completed successfully?

@cuporter,

Currently, there are only the two types requested and completed for the workflow_run event.

As a workaround, you can use the expression “github.event.workflow_run.conclusion” to get the result of the previous workflow run, and use the job 's if conditional to skip all the job in the current workflow run when the previous workflow run is not success.

name: Production deploy
on:
  workflow_run:
    workflows: ["Stage deploy"]
    types:
      - completed

jobs:
  job1:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}

  job2:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}

    . . .

  jobN:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}

Of course, you also can directly report a feature request that add more types for the workflow_run event (such as success and failure) here.
That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

1 Like