Github actions: Cancel redundant builds (Not solved)

Is it possible to auto cancel redundant builds?

Example: When a newer build is triggered on the same branch. Cancel running builds and start on the new one. 

Edit: In an attempt to remove the “solved” tag, this line was added.

82 Likes

No, it isn’t currently possible to auto-cancel redundant builds. I’ll pass along the feedback to the team, however.

Thanks!

50 Likes

@lee-dohm is this under consideration at all?

Here are the similar features in circle ci:

And Travis:

https://docs.travis-ci.com/user/customizing-the-build#building-only-the-latest-commit

Thanks!

8 Likes

This would be super useful imo!

1 Like

Would also love this feature :slight_smile:

1 Like

GitHub actions are going far beyond building things on push. A single workflow file can handle both push events and any arbitrary webhook event as well not direcly related to push.

It may become quite tricky to handle these scenarios. I’d imagine if this feature is introduced it should only be limited to few events where it make sense (push, pr synchronize etc) but not all.

Any update regarding this feature?

1 Like

any chance this could come sooon? this would help a lot when using mac machines. building an app on ios can take up to 30 min  and pushing constantly would be just expensive :/ 

3 Likes

Looking forward to this kind of feature! :slight_smile:

+1 building apps (mobile and electron) it is really expensive, when not canceling previous builds

2 Likes

This would be a really great addition. It’s tedious to do it will multiple jobs currently.

I’m adding my voice in support for that feature.
At Spendesk we just switched to GitHub Actions and the workflow we run is quite expensive. It would greatly help if we could save some computing power with this.

1 Like

I think its very strange to mark “pass along feedback” as an answer. This clearly is a feature request implicitly and should be handled as such _and_ would save GH and the users a lot of buildtime.

4 Likes

You are absolutely right. In hindsight I shouldn’t have marked it as “solved”.

@lee-dohm is it possible to get an update or an indication of this is something being worked on?

Hi all,

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/

2 Likes

I am also in favor of adding auto cancel build.

I understand that in some cases, this might not be desired, but many typical use cases - like “run tests” have absolutely no reason to run on an older push.

I would like to have the option to add a

jobs:
test:
runs-solo: true

or something similar in the configuration YAML, which will tell GitHub actions to make best-effort attempt to eliminate previous runs of the same workdlow.

4 Likes

I put together something simple that accomplishes this: https://github.com/marketplace/actions/workflow-run-cleanup-action - I use it as the first job of our CI run.

8 Likes

@mscoutermarshis it possible to get the Actions API permissions whitelisted for the GITHUB_TOKEN?

It doesn’t appear to be right now according to https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token#permissions-for-the-github_token

It is. The GITHUB_TOKEN has Read & Write access to the Actions API.

The docs are being updated. :slight_smile:

Thanks @mscoutermarsh - should there be any difference in the behavior for private repos?