How do `needs` and job dependencies work, and what happens when a needed job is skipped?
IntermediateConceptGitHub Actions
Answer
needs: [a, b] makes a job wait for both. If a needed job fails or is skipped, the dependent job is skipped by default. To run a job regardless, use if: always() or if: ${{ !cancelled() }} and inspect needs.<job>.result (success, failure, cancelled, skipped).
notify:
needs: [build, deploy]
if: always()
runs-on: ubuntu-latest
steps:
- run: echo "deploy was ${{ needs.deploy.result }}"
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate