Is it possible to cancel previous jobs automatically when the pull request is updated?

hi, I’m using GitHub actions to run CI jobs on the pull request. When the pull request is updated (e.g. new commits pushed), the new CI job is triggered, however previous jobs will continue to run which is not necessary. It is often annoying because a failed result mail may be sent to me. What I only care about is whether the HEAD of this pull request is ok to merge.



It’s not supported. Previous CI job is executed in a different github runner, it’s separated with the new CI job.

1 Like

What about local Action Runners?

1 Like

There’s a related question here:

We don’t have this exact feature, but we did just release an API that allows you to cancel builds.

I’m imagining something could be scripted to do this.

1 Like

I almost forgot to post my solution: I created a GitHub Action to cancel previous running workflows.

1 Like

I created another solution that solves this problem:
Other than cancelling previous jobs, it also prevents duplicate jobs after merges, pull requests or similar.