"Break early" if one of GitHub actions fails

302 Views Asked by At

Our CI setup is currently looking like this on GitHub:

enter image description here

Usually, first check is finishing much sooner than second check. It can succeed or fail. Is it possible (and if so - how) to "break early" and terminate remaining actions as soon as some action fails?

2

There are 2 best solutions below

1
On

You can do this easily but only within a single workflow. If you have multiple workflows.

strategy:
  matrix:
    os: [ubuntu-latest, macos-latest, windows-latest]
  fail-fast: true
0
On

It is possible, at least now, with a combination of some tools/APIs.

  1. Listen to step failure
    name: Stop Bitrise on Failure
        if: ${{ failure() && steps.demo.conclusion == 'failure' }}
        run: curl ...
  1. Use Bitrise Abort build curl From: Aborting Builds
curl -X POST -H "Authorization: ACCESS-TOKEN" "https://api.bitrise.io/v0.1/apps/APP-SLUG/builds/BUILD-SLUG/abort" -d "{}"
  1. Final result
    name: Stop Bitrise on Failure
        if: ${{ failure() && steps.demo.conclusion == 'failure' }}
        run: curl -X POST -H "Authorization: ACCESS-TOKEN" "https://api.bitrise.io/v0.1/apps/APP-SLUG/builds/BUILD-SLUG/abort" -d "{}"