This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Use Git Tags as additional Docker Image Tags #12
Open
kellervater
wants to merge
10
commits into
machine-learning-apps:master
Choose a base branch
from
saubermacherag:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
be2e50c
Allow customization of build docker image tag
creekorful f854f5a
Fix elif -> else
creekorful 4385a90
Rename shortSHA -> IMAGE_TAG
creekorful 135f213
Introduced CI for action testing. Added feature to use Git tags as
a23d891
updated README.md
67a6774
alternatively use dockerhub instead of gpr
d2af0b2
add documentation
6b726e8
Merge branch 'master' of https://github.com/machine-learning-apps/gpr…
d9cbb6d
Images can be pushed to GPR or Dockerhub
ed38130
use path argument to be fork agnostic
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM alpine:3.10.3 | ||
|
||
ENTRYPOINT ["echo", "'hello world'"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Test Dockerhub Push | ||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Copy Repo Files | ||
uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- name: Build and Publish Docker image to Dockerhub | ||
uses: ./ | ||
with: | ||
TAG: 'my-optional-tag-name' | ||
DOCKERFILE_PATH: '.github/docker/Dockerfile' | ||
BUILD_CONTEXT: '.' | ||
DOCKERHUB_REPOSITORY: 'pinkrobin/gpr-docker-publish-example' | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
env: | ||
REGISTRY_TOKEN: ${{ secrets.DOCKERHUB_PAT }} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
.idea |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,14 @@ The GitHub Package Registry allows you to develop your code and host your packag | |
|
||
This Action will automatically tag each image as follows: | ||
|
||
{Image_Name}:{shortSHA} | ||
{Image_Name}:{IMAGE_TAG} | ||
|
||
Where: | ||
- `Image_Name` is provided by the user as an input. | ||
- `shortSHA` is the first 12 characters of the GitHub SHA that triggered the action. | ||
- `IMAGE_TAG` is either the first 12 characters of the GitHub commit SHA or the value of INPUT_IMAGE_TAG env variable | ||
|
||
Additionally it will use Git Tags pointing to the HEAD commit to create docker tags accordingly. | ||
E.g. Git Tag v1.1 will result in an additional docker tag v1.1. | ||
|
||
## Usage | ||
|
||
|
@@ -57,7 +60,19 @@ jobs: | |
DOCKERFILE_PATH: 'argo/gpu.Dockerfile' | ||
BUILD_CONTEXT: 'argo/' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
#To access another docker registry like dockerhub you'll have to add `DOCKERHUB_UERNAME` and `DOCKERHUB_PAT` in github secrets. | ||
- name: Build and Publish Docker image to Dockerhub instead of GPR | ||
uses: saubermacherag/gpr-docker-publish@master | ||
with: | ||
IMAGE_TAG: 'v0.0' | ||
DOCKERFILE_PATH: '.github/docker/Dockerfile' | ||
BUILD_CONTEXT: './' | ||
DOCKERHUB_REPOSITORY: 'pinkrobin/gpr-docker-publish-example' | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
env: | ||
REGISTRY_TOKEN: ${{ secrets.DOCKERHUB_PAT }} | ||
|
||
# This second step is illustrative and shows how to reference the | ||
# output variables. This is completely optional. | ||
|
@@ -80,12 +95,15 @@ jobs: | |
|
||
1. `cache`: if value is `true`, attempts to use the last pushed image as a cache. Default value is `false`. | ||
2. `tag`: a custom tag you wish to assign to the image. | ||
3. `DOCKERHUB_REPOSITORY`: if value is set, you don't need to set `IMAGE_NAME`. It will push the image to the given dockerhub repository instead of using GPR. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure this is the best variable name. A Registry is different than an Image Name. Its also confusing to have both of these inputs which makes me wonder if we should rethink the api. |
||
Why? Because Github Actions don't support downloading images without authentication at the moment. See: https://github.community/t5/GitHub-Actions/docker-pull-from-public-GitHub-Package-Registry-fail-with-quot/m-p/32782 | ||
4. `DOCKERHUB_USERNAME`: required when `DOCKERHUB_REPOSITORY` set to true. | ||
|
||
## Outputs | ||
|
||
You can reference the outputs of an action using [expression syntax](https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions), as illustrated in the Example Pipeline above. | ||
|
||
1. `IMAGE_SHA_NAME`: This is the `{Image_Name}:{shortSHA}` as described above. | ||
1. `IMAGE_SHA_NAME`: This is the `{Image_Name}:{IMAGE_TAG}` as described above. | ||
2. `IMAGE_URL`: This is the URL on GitHub where you can view your hosted Docker images. This will always be located at `https://github.com/{OWNER}/{REPOSITORY}/packages` in reference to the repository where the action was called. | ||
|
||
These outputs are merely provided as convenience incase you want to use these values in subsequent steps. | ||
These outputs are merely provided as convenience incase you want to use these values in subsequent steps. |
This file contains 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
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this repo has authorization to push to this repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's true. This is just intended for testing purposes.