Skip to content
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

docker build github action #508

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

brandonmcclure
Copy link
Contributor

This is a workflow that I have been using to build/publish docker images on github. To push to docker hub, you need to create a access token and set a DOCKERHUB_USERNAME and DOCKERHUB_TOKEN action secret.

On a PR to master, or if run manually from non master branch, this workflow will build the Dockerfile, but not push.
On any push to master, it will build, and publish to your github container registry, and docker hub

This will publish a image with the latest, 'master','master.commitsha' tags

@hexparrot hexparrot self-requested a review September 30, 2022 15:20
@hexparrot
Copy link
Owner

Thanks for this PR. So I can fully understand what I'm looking at, can you help me with this portion:

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: hexparrot/mineos-node
  JUST_IMAGE_NAME: mineos-node

Per docker hub, it's hexparrot/mineos. I've created the access token--is the registry and image name appropriate here, or should I be changing it to the shortened name. And ghcr.io, is that appropriate? I'm not famliiar with that host.

@brandonmcclure
Copy link
Contributor Author

brandonmcclure commented Sep 30, 2022

good catch on the image name miss-match. Use the shortened name.
ghcr is git hub's container registry. I like pushing to it in addition to docker hub to increase reach since publishing the images happens automatically, and there is no increased security risk/secret setup to use it. remove this and change the built tags here

We/I can re-write it to only use IMAGE_NAME as well, idk what I was thinking for JUST_IMAGE_NAME...

If you want both docker hub and ghcr:

images: |
  ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  ${{ env.IMAGE_NAME }}

Just docker hub could be shortened to:

images: |
  ${{ env.IMAGE_NAME }}

@valeryan
Copy link

It would be cool to get the docker hub updated again. The PR follows along with the last example from GitHub docs. https://docs.github.com/en/actions/publishing-packages/publishing-docker-images so that may help with context.

@valeryan
Copy link

I did an experiment to confirm that you can publish correctly using a GitHub action. I used the example for just the docker hub - https://github.com/valeryan/mineos-node/blob/master/.github/workflows/dockerhub.yml. this one is set to trigger on publishing a release. And it was published to my account using my credentials. https://hub.docker.com/repository/docker/valeryan/mineos-docker/general.

My Steps:

  1. Fork repo
  2. Generate a token on the docker hub to use as the password
  3. Add secrets for username and password using my username and the token created in step 2.
  4. Merged my action into my fork
  5. Published a release to test tagging
  6. Allowed action to push to the docker hub.

I will delete all that later but I figured it would be fun to see it work for myself and I have a new docker image to use for now that's not super outdated...

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.

3 participants