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.

5 Likes

Hi,

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: https://github.community/t5/GitHub-Actions/Github-actions-Cancel-redundant-builds/td-p/29549

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.

https://developer.github.com/v3/actions/

1 Like

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

https://github.com/marketplace/actions/cancel-workflow-action

1 Like

I created another solution that solves this problem: https://github.com/marketplace/actions/skip-duplicate-actions
Other than cancelling previous jobs, it also prevents duplicate jobs after merges, pull requests or similar.