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

Add Docker push to GitHub Package Registry #179

Merged
merged 1 commit into from Nov 8, 2019

Conversation

@josh
Copy link
Contributor

josh commented Nov 2, 2019

I'm very excited about Docker support in GitHub Package Registry.

I wanted to create a starter workflow for people already using and familiar with Docker Hub's automated builds and automated testing workflow.

This PR replicates 3 of the core behaviors.

  1. Run docker compose based test suite. Known as "Autotest" on Docker Hub.
  2. Build and publish master to latest tag. While master is a git convention, latest is the default tag that's pulled by default.
  3. Also build and publish tags to corresponding names.

Each of these behaviors is easily modified or disabled if someone only wants to publish releases rather than any pushes to master.

Would love feedback on some of the naming conventions I used in the workflow.

Paired with @myobie
Advice from @mattyoho and @pmarsceill

IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

This comment has been minimized.

Copy link
@josh

josh Nov 2, 2019

Author Contributor

I was hoping there would be a more straight forward way to access the "short revision" you'd get out of something like git rev-parse --short HEAD. Maybe supporting ${{ github.short_ref }} could be a handy feature to upstream.

run: docker build . --file Dockerfile --tag image

- name: Login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

This comment has been minimized.

Copy link
@josh

josh Nov 2, 2019

Author Contributor

Security check: Is this the best way to pass the auth token?

I was hoping to also silence this warning.

WARNING! Your password will be stored unencrypted in /home/runner/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
ci/docker-push.yml Outdated Show resolved Hide resolved
Copy link
Contributor

myobie left a comment

@josh we maybe should use github.repository as the default for the env var.

@josh

This comment has been minimized.

Copy link
Contributor Author

josh commented Nov 2, 2019

we maybe should use github.repository as the default for the env var.

GPR requires the format OWNER/REPOSITORY/IMAGE_NAME. We include OWNER/REPOSITORY (aka github.repository) by default. But IMAGE_NAME is kinda up to the author. I'm not super sure what most people are going to choose here. Maybe just the repository name repeated?

@josh josh requested a review from anthonysterling Nov 4, 2019
Co-authored-by: Nathan Herald <me@nathanherald.com>
@myobie
myobie approved these changes Nov 4, 2019
Copy link
Member

mscoutermarsh left a comment

Thanks @josh!

@mscoutermarsh mscoutermarsh merged commit 2ce3a0e into actions:master Nov 8, 2019
@mscoutermarsh

This comment has been minimized.

Copy link
Member

mscoutermarsh commented Nov 8, 2019

FYI @clarkbw

@josh josh deleted the josh:docker branch Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.