workflows: Cancel previous jobs if PR/branch is updated #2129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During some testing on my fork and sometimes when running PR testing I've found that I want to re-push whilst the existing CI runs are still going and I need to go in and cancel the old jobs first. This PR looks to address this.
Update our (non-callable) jobs to cancel if another push is done to the PR, or branch, or the unlikely event that another cron job is triggered in order to save time and costs running out of date jobs.
Approach based on stack overflow suggestion:
This is based on the following stack overflow suggestion: https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre which is the same approach that kata-containers uses.
Some of these feel a bit redundant as the jobs are quite short e.g. the commit-message-check, but I
figured that for consistency's sake there wasn't any harm in updating these anyway.