build-push-action icon indicating copy to clipboard operation
build-push-action copied to clipboard

Option to not push if a pull/rebuild hasn't changed anything and a boolean output `rebuilt`

Open nitrocode opened this issue 4 years ago • 4 comments

I'd like to

  • provide an option to not push if there isn't a rebuild
    • push_if_changed: true or similar ?
  • know if the container had to rebuild, perhaps with an output
    • If it doesn't, then I know that there must have been file changes in the branch commits ignored successfully by the .dockerignore. If the container does not have to rebuild, then I do not have to redeploy the app.

We can detect if a previous build is the same as current build by comparing the Id which doesn't change if the docker build doesn't change.

docker inspect --format {{.Id}} $docker_image_name

Source: https://stackoverflow.com/a/45306984/2965993

nitrocode avatar Aug 18 '21 19:08 nitrocode

This would be very useful for me too.

Aankhen avatar Aug 21 '21 18:08 Aankhen

Instead of having a new option push_if_changed, reusing push should be posible by referencing some new variable. So instead of just push: true for example, using something like push: ${{ image_has_changed }}.

gdvalderrama avatar Sep 03 '21 10:09 gdvalderrama

This would be part of the build reproducibility we have started to work on: https://github.com/moby/buildkit/blob/master/docs/build-repro.md.

crazy-max avatar Jan 17 '22 16:01 crazy-max

Hello, any update on this one?

danieletorelli avatar Nov 01 '22 08:11 danieletorelli

Closing as this is not directly related to the action but BuildKit (maybe Buildx as well). See also https://github.com/moby/buildkit/blob/master/docs/build-repro.md#source_date_epoch and https://github.com/docker/build-push-action/issues/994#issuecomment-1805831110

crazy-max avatar Mar 08 '24 14:03 crazy-max

Closing as this is not directly related to the action but BuildKit (maybe Buildx as well). See also https://github.com/moby/buildkit/blob/master/docs/build-repro.md#source_date_epoch and #994 (comment)

I’m not sure how what you linked helps us… Please reconsider this issue.

douglasparker avatar Mar 08 '24 19:03 douglasparker