-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Create GH Actions workflow to build Docker image #1184
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
Conversation
This is so that pull requests that modify the docker image but don't have the DOCKER_HUB_USERNAME secret set won't fail.
Instead of just checking if it's not pull_request
Uses either the DOCKER_HUB_USERNAME secret or just infinitime as the username for pushing to and pulling from Docker Hub.
|
@FintasticMan That looks very good 👍 And it even builds for amd64 and arm64 ! 🏅 Regarding the tags : is there anyway to handle them 'automatically'? If you have a look at the docker repo for InfiniTime, I pushed 2 tags when I updated the image : the tag |
|
You can definitely push to multiple tags at once, but I'm also not sure of a good versioning system for it. Perhaps it should push to its commit hash and latest. Another thing I was thinking of doing was pushing the builds to the GitHub Container Repository on pull requests. It would then be put under the username of whoever made the pull request. |
3a97761 to
4371dea
Compare
4371dea to
2e61937
Compare
|
@FintasticMan Thanks for your PR #1023! Perfect timing to merge this one so we can test the automatic build :)
For now, I'm just using an incrementing counter, but I'm doing it manually. Not sure how to automate that using the Action build. The idea was to keep older versions of the image on the Docker repo along with the new one (latest). Is this something we want/need? Or can I create this "version" tag manually after it has been pushed as "latest"? |
|
I'm not sure if it would be possible to have an incremental counter for the tag. I'm sure that manually adding the image to the "version" tag won't be necessary. It should be quite doable for the image to be pushed to the tag corresponding to the git commit hash it was built from. This would mean that an image would be pushed to the Is this a good enough solution? |
|
I have done similar things with just a single Dockerfile, where I use the SHA256 checksum of that file as a tag. That makes it easy to detect if anything a has changed. It can quite easily (via a simple python script for instance) be extended to calculate a checksum over multiple files as well. |
|
@JF002 I have now pushed a change that makes it push to latest and the commit shasum. You can see how it looks here. It was pushed by the workflows in this PR: FintasticMan#6. |
|
@FintasticMan that looks good to me! We'll use the commit sha as tags and see if we ever need older tags of the images!
I've never used secrets in Github. Should I create an |
|
It needs to be a repository secret. |
|
@FintasticMan What will trigger the build and push of a new image? If I understand correctly, the workflow will be triggered on push and pull-requests on both
I think we should try to generate (and publish) the image only when changes are merged in develop. What do you think? |
|
@JF002 At the moment, pushes to I think that this is behaviour that makes sense, except for that it should only be for Edit: I've just pushed that change. |
|
@FintasticMan Thanks for those informations about the workflow. It looks good to me! |
|
@FintasticMan So, I've just merged this branch and #1203. I forgot the setup the username in the settings of the project, so it took 1 or 2 trials. |
|
Thanks for the heads up. I'll have a look when I get back to my PC. |
|
@FintasticMan Awesome, thank you very much! I wasn't sure which username needed to be changed! I'll have a look at that PR! |
This PR adds a GitHub Actions workflow that builds the Docker image and pushes it to Docker Hub whenever anything in the
docker/directory is changed. I've tested it here, and the images have been pushed here.Any pull requests should just build the image, but not upload it to Docker Hub. It should also be possible to publish to different tags than just latest by using docker/metadata-action, I just haven't gotten around to that yet.
Before merging, the secret
DOCKER_HUB_ACCESS_TOKENwill be needed to be added to this repository.