docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.24k stars 541 forks source link

Allow to cancel build #896

Closed bettinaheim closed 1 year ago

bettinaheim commented 1 year ago

We recently switched from using docker build in a script to using the build-and-push action. An unintended side effect of this has been that cancelling a workflow more or less immediately is no longer possible it seems; Any cancellation request on GitHub, whether manual or due to the defined concurrency, does not terminate the docker build-and-push steps. Since our docker builds take quite long, this is a significant downside. Is there a way to force the cancellation of a build-and-push step?

More details after some observation: The issue seems to be specifically that the build-and-push step is not cancelled if push: true is specified. If push and load are false, and a tar output is requested, the job gets cancelled just fine.

crazy-max commented 1 year ago

is no longer possible it seems

Can share a full repro for this please? I can't repro atm. Would like to see a workflow and Dockerfile to try to repro on my side.

bettinaheim commented 1 year ago

This may have been my mistake. We have a condition of the form

if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')

and I overlooked that it was possible that none of the needs before would be in a cancelled state. I amended that do include an explicit && ! cancelled() now. I'll close this issue with my thanks for the swift reply.