Workflow wide fail fast

If any job in my workflow fails I want all jobs to be canceled and the workflow to terminate as quickly as possible so runner resources can be freed up for other workflows.

Is this possible to achieve?

Hi @nedrebo,

For common parallel jobs, you can add below code to the end of each job, if there is an error, it will cancel the workflow.

      - name: cancel workflow
        if: failure()
        uses: andymckay/cancel-action@0.2


If you use matrix for parallel jobs, it will automatically cancel in progress jobs since ‘fail-fast’ is true by default.


Thx for the pointer. Manually adding that code block to all jobs is not a good solution, we cannot do that for maintainability reasons.

We ended up adding a compiler for YAML files that add things like this to the YAML automatically. This way we can make extensions to the language while we wait for upstream to catch up.

We also implemented support for `needs` based on `matrix` and to have a “finalizer” job that needs all other jobs, without manually maintaining the needs list. Used for deploying.

All in all, this compiler reduces our workflow file from 2500 lines to 500 lines so I really hope GA gains more features for code reuse and advanced workflows. So this seems to work well for us whenever GA features are too limited.