How does `needs` work, and what happens to a job whose dependency failed or was skipped?
BeginnerConceptJobs, Steps, Matrix & Concurrency
Answer
needs: [build, test] makes a job wait until both finish successfully. If any needed job fails, is cancelled, or is skipped, the dependent job is skipped by default, and the skip propagates transitively down the chain. To run anyway, add a status function to the job if:
deploy:
needs: [build, scan]
if: ${{ !cancelled() && needs.build.result == 'success' && needs.scan.result != 'failure' }}
More on Jobs, Steps, Matrix & Concurrency
What is the implicit `success()` in a job `if`, and why is `always()` usually the wrong fix?IntermediateWhat values can `needs.<job>.result` take?BeginnerHow does a matrix expand, and how are job names generated?BeginnerHow do `include` and `exclude` work in a matrix?IntermediateWhat do `fail-fast` and `max-parallel` do?BeginnerHow do you build a matrix dynamically from a previous job?Advanced