Cancel a running Action if the triggering PR gets updated?

I’m in the process of migrating our website CI/CD workflow over to GitHub Actions. Currently, the process is triggered by webhooks from GitHub for the pull_request and commit events.

Some of our websites can take a long time to build and we’ve seen situations where a PR can be updated while an existing build is taking place. For example, a contributor might raise a PR then, while they are waiting, realise they’ve got a spelling mistake in their contribution and fix it, thus updating the PR.

In our code that is triggered on the pull_request event, we spot this by checking any ongoing builds and cancelling any that are for the same pull request.

My question is this: is there any way to achieve the same goal with Actions?


Currently, there is no any built-in feature that can automatically cancel the previous runs of a workflow on GitHub.

However, there are some actions published on the GitHub Marketplace, see here.
You use one of them in your workflow to cancel the previous runs of the workflow.

1 Like