You need a cleanup job that runs when the workflow is cancelled mid-flight, but not on a normal successful completion. Which job-level condition is appropriate?
Select an answer to reveal the explanation.
Short Explanation
cancelled() is the status function built for cancellation paths. failure() only covers failed jobs or steps; always() would also run on success, which you do not want here.
Full Explanation
GitHub Actions provides four status check functions for if: conditions: success(), failure(), cancelled(), and always(). cancelled() evaluates to true when the workflow was cancelled (for example via the UI, concurrency cancel-in-progress, or API). That makes it ideal for a dedicated cleanup job that tears down ephemeral resources only when a run is aborted. failure() is true when a previous dependency failed, not when the run was cancelled. always() && success() is contradictory for cancellation — success() is false when cancelled. There is no github.cancelled property. Combine needs with cancelled() carefully: if the cleanup job needs other jobs, those upstream jobs may report cancelled as well; use if: always() when you must run cleanup regardless of upstream outcome, or if: cancelled() when you only care about the cancelled case.