In a GitHub Actions workflow with jobs 'build', 'test', and 'deploy', how do you ensure 'deploy' only runs after both 'build' and 'test' succeed?
Select an answer to reveal the explanation.
Short Explanation and Infographic
The 'needs:' keyword is the job scheduler's way of saying 'wait for these jobs to finish and pass before starting me'.
Full explanation below image
Full Explanation
'needs:' accepts a single job ID or a list of job IDs that must succeed before the current job runs. If any listed job fails, the dependent job is skipped by default. 'after:', 'depends_on:', and 'requires:' are not valid GitHub Actions keywords — they come from other CI systems (CircleCI uses 'requires:', GitLab uses 'needs:', Buildkite uses 'depends_on:'). The 'needs:' context also lets you access outputs from dependency jobs.