Skip to content

Instantly share code, notes, and snippets.

@mpdude
Last active Jan 15, 2020
Embed
What would you like to do?
Build Docker image and push it to GPR
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: machine-learning-apps/gpr-docker-publish@5b71bce8513330a62b8b61ba846d37caaf2a85ba
with:
image_name: 'my-image-name'
dockerfile_path: 'Dockerfile'
build_context: '.'
cache: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@mpdude
Copy link
Author

mpdude commented Jan 15, 2020

This is the most concise way to do...

  • docker login docker.pkg.github.com ... with your GITHUB_TOKEN
  • docker build ... from the dockerfile_path file with the build_context directory as context
  • Create an image named according to image_name
  • docker push to GPR

This will push into GPR within the repo that the action runs for.

So, for example, if this workflow lives in github.com/myorg/myrepo, the image will show up in github.com/myorg/myrepo/packages, and can be pulled with docker pull docker.pkg.github.com/myorg/myrepo/my-image-name.

Also, the image will be tagged with the SHA1 of the git commit that the action was run for.

cache pulls the latest version of the package and uses it as a build cache.

Note: In order to use the image from an other action, even if the repository hosting the image is public, you will need to docker login.

docker login docker.pkg.github.com --username username-ignored --password-stdin <<< '${{ secrets.GITHUB_TOKEN }}' should be sufficient.

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