A developer wants a workflow job to continue running its remaining steps even if one particular step fails, but the overall job should still be marked as failed at the end. Which configuration achieves this on the individual step?
- A. Set
continue-on-error: trueon the job - B. Set
if: always()on each subsequent step in the job - C. Set
continue-on-error: trueon the step✓ Correct - D. Wrap the step command in
|| truein the shell script
Explanation
continue-on-error: true on a step allows subsequent steps to run if that step fails, while the job itself is still ultimately marked failed — exactly the described behavior. B is wrong because setting continue-on-error: true on the job level causes the entire job (and dependent jobs using needs) to be treated as successful even when steps fail, which is too broad. C is wrong because || true makes the shell command exit with code 0, meaning GitHub Actions never sees a failure at all — the step is marked as passed, not just continued past. D is wrong because if: always() on subsequent steps would make them run regardless, but the failing step itself would still halt execution of later steps by default unless combined with another mechanism; it also doesn't control the job's final status in the desired way.