-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build flag similar to push flag #17
Comments
Thanks for your feedback @garethr. I've put this suggestion onto the backlog and will discuss it with our PM 👍 |
Implementing this one would help a lot with third party building tools, e.g. sbt's Perhaps a pair of separate actions for |
@zappy-shu I was planning to volunteer to submit a PR for this, but I am not sure where the source code is. It looks like it uses the https://hub.docker.com/r/docker/github-actions container, but I don't see a dockerfile or source repo for it. Please tell me that the default github actions are not closed source! If you have a repo where the code is, I am happy to submit a PR. |
@shankari the whole of docker's github action is open-source with the backend image being built from https://github.com/docker/github-actions. It's been separated for a few reasons, the main one being in case we wish to use the image as a backend for other actions. Please feel free to open a PR if you wish to contribute. One of the big questions is how to deal with tags. The current flow of this action builds the image with all the tags defined in
One thing I think is essential is for the action to output what tags it builds and/or pushes with as per #24. Most likely 2 outputs:
A simple way to deal with it is to not bother with retagging and just try and push all the tags given. E.g. # Builds the image and tags it as myorg/myrepo:foo and myorg/myrepo:{ref}
- name: build
id: build
uses: docker/build-push-action@v1
with:
repository: myorg/myrepo
tags: foo
tag_with_ref: true
push: false
### Do other stuff
# Pushes the image with tags myorg/myrepo:foo and myorg/myrepo:{ref}
- name: push
uses: docker/build-push-action@v1
with:
build: false
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: myorg/myrepo
tags: ${{ steps.build.outputs.version_tags }} This is relatively simple but doesn't allow retagging between the build and push. Another option is to have some sort of "original image" input that is used simply to find the initial image in the push step which is then retagged and pushed with the new tags. E.g. # Builds the image and tags it as myorg/myrepo:foo
- name: build
id: build
uses: docker/build-push-action@v1
with:
repository: myorg/myrepo
tags: foo
tag_with_ref: true
push: false
### Do other stuff
# Pushes the image with tags myorg/myrepo:{ref}
- name: push
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: myorg/myrepo
original_image: ${{ steps.build.outputs.full_tags }}
tag_with_ref: true As an aside, because of build caching, rebuilding the image shouldn't actually cost that much time unless the steps between the initial build and the build-push break the cache somehow (modifying files or the like). @nebuk89 any thoughts? @garethr it'd be great to have your opinion on how you envisage the flow working as well |
The main drawback of rebuilding the image is that is breaks "build-test-promote" concept. In other words, you want to test what you've built before pushing and want to push exactly the image you tested. |
@khitrenovich agreed. It's not ideal so was just a side note for those only worried about CI/CD time |
We are still considering whether to do a separate build action or just have a build flag in this action (we will start the 'doing' very soon either way!) What do people prefer? 🤔 |
@zappy-shu I like the explicit nature of I think it's worth considering the various compositions here as well. ie.
This raises the question of, can you benefit from things like |
When I volunteered to write the PR, I was planning to have an "original image" output from the build step that would be something like |
Will the "separate action" also have support for multiple repositories (e.g. dockerhub, github packages, etc)? |
Should we just provide 3 separate actions (push, build, build&push) based on the same underlying docker container (i.e. https://github.com/docker/github-actions)? I doubt it introducing a new input would do any good. |
I think having a new input is the way to go, it follows the same principles outlined here https://www.docker.com/blog/first-docker-github-action-is-here/ I do not have anything to add other than what they already said in the article. |
@nebuk89 - do you have a timeline for resolution of this issue? |
To add my two cents here, I'd definitely appreciate the option of specifying an original image, which then gets tagged according to the input parameters (e.g. static tags, tag by ref, tag by SHA, ...) and pushed to the repository. I think this is pretty much the second way which @zappy-shu proposed. This would allow me to build the image myself in an earlier step with an action of my choice (e.g. |
When build is done with another tool, e.g. |
Hi everyone, This will be available through build-push-action v2 (#92). |
Version 2 has been merged to the main branch and is therefore available via As a reminder, this new version changes drastically and works with 3 new actions (login, setup-buildx and setup-qemu) that we have created. Many usage examples have been added to handle most use cases. And it should fix this current issue. Don't hesitate if you have any questions. |
I've been poring the docs trying to understand how to compose the original point of the issue and the current usage examples. Two of them are relevant but don't quite fully approach the options mentioned in #17 (comment). The usage of testing before pushing shows an example of testing the image and then re-running If so, I don't understand how this resolves the issue where you want to be able to push a previously-built image, unless one is meant to make use of something like copy between registries where you use the |
Agreed — I don't think this issue should have been marked as closed, as there's no way to skip a build and only push. |
Maybe build flag could be introduced with functionality like that
(where /ping @crazy-max |
Here is my current workaround:
|
@crazy-max Can you please reopen this issue? |
At present it's possible to set
push
to false and just build an image. This is useful when you want to test the image before pushing it. But when you do that, pushing becomes either a matter of doing so manually (potentially with multiple tags), or triggering the full action again, including a build.It would be useful to run just the push action, maybe by adding a property for
build
that defaults to true?The text was updated successfully, but these errors were encountered: