Skip to content

Add Docker image publish Github action - #97

Merged
anacrolix merged 3 commits into
anacrolix:masterfrom
pataquets:add-docker-publish-image-action
Jul 6, 2022
Merged

Add Docker image publish Github action#97
anacrolix merged 3 commits into
anacrolix:masterfrom
pataquets:add-docker-publish-image-action

Conversation

@pataquets

@pataquets pataquets commented Jul 4, 2022

Copy link
Copy Markdown
Contributor

Finally, I managed to solve #69 using Github Actions, no need to grant access to Docker Hub to your Github repos, since it will be Github which will build and push the image to DH. 🎉

Github Action requires DOCKERHUB_USERNAME and DOCKERHUB_TOKEN (generated on DH's security settings page) to be set in the Github secrets section in the repo config.
Git pushes will trigger this Github Action to build Docker images and push them to Docker Hub:

  • Git branch branchname pushes dms:branchname image tag. Thus, dms:master acts as an edge/unreleased/HEAD image tag. Other branches push to their respective image tags (useful for testing feature branches),
  • Git tags vX.Y.X push to dms:X.Y.Z, dms:X.Y, dms:X and dms:latest.:latest tag is the default if no tag specified, so docker pull anacrolix/dms pulls latest released (stable) git tag.

Also enabled Dependabot (only for Github Actions manifests). No need to toggle or configure anything.

Check out action runs and image tags from my testing on my repos.

@anacrolix

Copy link
Copy Markdown
Owner

I pushed this branch to one of the same name for this repo, it generated https://hub.docker.com/layers/247489278/anacrolix/dms/add-docker-publish-image-action/images/sha256-3c9fdb05e699f5973870f248944b516f03d19fc982082793512674da0d166f88?context=repo. Looks good? Do I need to do anything to get it to generate previous tags, or does it just do it going forward? When I moved/merge this with master, I'm guessing a master image will be generated?

@pataquets

pataquets commented Jul 5, 2022

Copy link
Copy Markdown
Contributor Author

The image looks good. I've done a cursory run on my PC, looks good. As soon as you merge it, :mastertag will get pushed.
I'm not sure, but maybe the SemVer image tags don't generate until a new version git tag is pushed, no previous tags. Just pushing a new release git tag would generate :1, :1.x, :1.x.yand :latest image tags (the latter is expected as a standard practice).
From the top of my head, no way of generating previous tags, AFAIK. Some sort of deleting tags on Github and re-pushing them (at the same commit ids) come to mind, but it has obvious caveats. If I come with any solution I'll let you know.

For reference, check out my test image tags (pay attention to image hashes to see the same image pushed to multiple tags).

@anacrolix
anacrolix merged commit c6bb67a into anacrolix:master Jul 6, 2022
@pataquets
pataquets deleted the add-docker-publish-image-action branch July 12, 2022 00:19
@pataquets

Copy link
Copy Markdown
Contributor Author

@anacrolix Keep in mind that until a tagged version is pushed, the only usable image tag is :master (which is not default), and therefore any image run or pull without specifying that tag will fail, as :latest is always assumed if no tag provided, as explained above.

$ docker run --rm -it anacrolix/dms
Unable to find image 'anacrolix/dms:latest' locally
docker: Error response from daemon: manifest for anacrolix/dms:latest not found: manifest unknown: manifest unknown.
See 'docker run --help'.

@anacrolix

Copy link
Copy Markdown
Owner

I've just pushed v1.5.0. Let me know if it doesn't work out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants