How to make github actions step fail if the previous step has failed?

Viewed 389

I have written a ci process to build and deploy docker images using github actions. There is a strange behavior seen i.e. when the make file fails due to any reason the steps in the github actions are still continued instead of stopping at the failed step. I am using only one job in my ci and multiple steps within it.

Example error: make[1]: [../../Makefile:22: docker-build-generic] Error 1 (ignored)

1 Answers

Github Actions do not actually run sequentially: they will run in parallel if there are enough resources. If one job relies on another, use the needs syntax.

Modified example from the documentation:

jobs:
  job1:
  job2:
    needs: job1

Here job2 will wait for job1 to succeed before running. If job1 fails, job2 will not run.

Related