Last active
January 15, 2020 16:57
-
-
Save mpdude/2e37eca2a9d9b97d6f8038bd48cf1849 to your computer and use it in GitHub Desktop.
Build Docker image and push it to GPR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the most concise way to do...
docker login docker.pkg.github.com
... with yourGITHUB_TOKEN
docker build ...
from thedockerfile_path
file with thebuild_context
directory as contextimage_name
docker push
to GPRThis 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 ingithub.com/myorg/myrepo/packages
, and can be pulled withdocker 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 thelatest
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.