Github actions: Cancel redundant builds (Not solved)

@mscoutermarsh is there some place to see the preview of the API and/or comment on it?

Working on the “auto-cancel” action a bit more, I’m discovering some hidden features of the API. Turns out that not only is run_id a part of the github context, but there is even a GITHUB_RUN_ID environment variable, which is very convenient! However, there is no workflow_id, which I find strange - and although you can refer to the workflow by its filename, you also can’t get that information from any of the context or environment variables afaict.

Hi @rokroskar

Here are the docs for the Actions API:

We’re still making tweaks to the docs and highlighting more things (like the RUN_ID you found).

Great feedback on the workflow_id, we had been discussing that. It’s something we’ll consider adding. Thanks!

1 Like

Very nice. Works perfectly and easy to setup.

Is there any way to disble the GitHub cancelled emails?

  • 1    This is currently creating problems with our deployment workflows. They stack and timeout even when the last one was successful. Definitely a required feature.

I’ve created an action for that purpose. Feel free to create issues, or provide any feedback!

It can cancel all previous builds in repo, but requires personal token in secrets, and worflow names to filter what to cancel.

We also spent $150/mo. for CircleCI, but now paid more than $800/mo… Quite regretful…;

I’ve created a new one in javascript :

Could you remove the “Solution” checkmark from this, please? Nothing has been solved. This is still a big, costly issue for many of us.

1 Like

@tonyarnold that is not possible. I have edited the text now and pressed “Mark as new” hoping that this will bump the issue back up.

Hi there @mscoutermarsh! Your name is vaguely familiar :slight_smile: Remember the good old days taskking? 

What’s the status on this? I’m only using actions for open source so it isn’t a cost issue for me. I’d just love to be able to use as little resources as possible to avoid hogging computing power that isn’t needed.

@mhenrixon !! :heart::heart:

Best option for this currently is using an Action. Such as: It uses the Actions API to cancel previous builds.

We want to have this built in at some point in the future. In mean time, this Actions works great.


That’s a very missing feature to build a reliable workflow. Using action is kinda kludge, ideally, it should be core functionality.

I found the staff recommended action didn’t work and couldn’t figure out why, I then tried three others that also didn’t work, and I couldn’t figure out why.

This one is more elegant that the others I tried (add to the workflow you want to cancel and a single line to boot) and bonus! (I think) it even works too:


FTR those GitHub Actions will only help with builds that are not triggered on pull_request event. PRs from forks have a GH secret with privileges limited to “Read”.

Give that this can spike up the build minutes a lot, this would probably be really worth to have officially supported.


The technote action works fine. Would be nice to have it as option in your workflow indeed. Our team is doing a feature request on their enterprise account. Maybe more clients overhere can do this to give it more weight?

I published another tool that solves this problem:
Other than cancelling redundant builds, it also prevents duplicate workflow-runs after merges, pull requests or similar.