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

Add option to build only without push

Open peterbandi opened this issue 3 years ago • 10 comments

It would be nice to have an option to just build an image to see if the Dockerfile is correct without pushing the result. For example with pull requests one would like to know if the proposed Dockerfile builds, but the resulting image should not be pushed to a docker repository. Please add an input of boolean type to control the pushing of the built image.

peterbandi avatar Jul 08 '22 14:07 peterbandi

Hi @peterbandi - thanks for the feature request. I can consider adding a flag such as pushImage that would be set to true by default for backwards compatibility.

mr-smithers-excellent avatar Jul 09 '22 20:07 mr-smithers-excellent

That would be perfect.

peterbandi avatar Jul 10 '22 08:07 peterbandi

I agree to that.

scolastico avatar Aug 12 '22 08:08 scolastico

I came here to ask for this same thing :)

justinmchase avatar Aug 19 '22 16:08 justinmchase

Well then, I must give the people what they want! Will get started on this feature right away.

mr-smithers-excellent avatar Sep 14 '22 22:09 mr-smithers-excellent

@peterbandi @scolastico @justinmchase - I have added this feature in a branch.

Can one of you please give this a try using the following workflow settings and let me know if it achieves the intended functionality?

uses: mr-smithers-excellent/docker-build-push@feat/push-flag
with:
  image: [image]
  pushImage: false # new optional input 
  registry: [registry]
  username: [username]
  password: ${{ secrets.DOCKER_PASSWORD }}

mr-smithers-excellent avatar Sep 15 '22 04:09 mr-smithers-excellent

Do you need a registry/username/password if you're not going to push?

Also just a recommendation but maybe:

mode: 'build' # or 'build_and_push' (default)

justinmchase avatar Sep 16 '22 06:09 justinmchase

@justinmchase - username/password no, registry is still prefixed to the image name currently.

mr-smithers-excellent avatar Sep 20 '22 22:09 mr-smithers-excellent

Nice job, ty! 👍🏻

scolastico avatar Sep 20 '22 22:09 scolastico

Also btw did you thought about changing the registry default value to ghcr.io? Because this is the most used value on gh.

scolastico avatar Sep 20 '22 22:09 scolastico

pushImage: false

@mr-smithers-excellent Sorry for the late reply. We had a deadline. It works as intended. I can prevent image pushing with pushImage: false while the built image is pushed to the docker repository with pushImage: true or by leaving out the pushImage option.

peterbandi avatar Oct 05 '22 11:10 peterbandi

Excellent! This feature is now available in the v5 and v5.8 releases.

mr-smithers-excellent avatar Oct 06 '22 04:10 mr-smithers-excellent