This repository was archived by the owner on Dec 9, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +50
-44
lines changed Expand file tree Collapse file tree 6 files changed +50
-44
lines changed Original file line number Diff line number Diff line change 1+ name : Test Dockerhub Push
2+ on : [push]
3+
4+ jobs :
5+ build :
6+ runs-on : ubuntu-latest
7+ steps :
8+
9+ - name : Copy Repo Files
10+ uses : actions/checkout@v1
11+ with :
12+ fetch-depth : 1
13+ - name : Build and Publish Docker image to Dockerhub
14+ uses : saubermacherag/gpr-docker-publish@master
15+ with :
16+ TAG : ' my-optional-tag-name'
17+ DOCKERFILE_PATH : ' .github/docker/Dockerfile'
18+ BUILD_CONTEXT : ' .'
19+ DOCKERHUB_REPOSITORY : ' pinkrobin/gpr-docker-publish-example'
20+ DOCKERHUB_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
21+ env :
22+ REGISTRY_TOKEN : ${{ secrets.DOCKERHUB_PAT }}
Original file line number Diff line number Diff line change 1- name : Tests
1+ name : Test GPR Push
22on : push
33
44jobs :
77 steps :
88
99 - name : Copy Repo Files
10- uses : actions/checkout@master
11-
10+ uses : actions/checkout@v1
11+ with :
12+ fetch-depth : 1
1213 - name : Publish Docker Image to GPR
13- uses : machine-learning-apps /gpr-docker-publish@master
14+ uses : saubermacherag /gpr-docker-publish@master
1415 with :
1516 IMAGE_NAME : ' test-docker-action-v2'
1617 TAG : ' my-optional-tag-name'
1718 DOCKERFILE_PATH : ' Dockerfile'
1819 BUILD_CONTEXT : ' .'
1920 env :
20- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
21+ REGISTRY_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -60,18 +60,19 @@ jobs:
6060 DOCKERFILE_PATH : ' argo/gpu.Dockerfile'
6161 BUILD_CONTEXT : ' argo/'
6262 env :
63- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
63+ REGISTRY_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6464
6565 # To access another docker registry like dockerhub you'll have to add `DOCKERHUB_UERNAME` and `DOCKERHUB_PAT` in github secrets.
6666 - name : Build and Publish Docker image to Dockerhub instead of GPR
6767 uses : saubermacherag/gpr-docker-publish@master
6868 with :
69- USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
70- PASSWORD : ${{ secrets.DOCKERHUB_PAT }}
7169 IMAGE_TAG : ' v0.0'
7270 DOCKERFILE_PATH : ' .github/docker/Dockerfile'
7371 BUILD_CONTEXT : ' ./'
7472 DOCKERHUB_REPOSITORY : ' pinkrobin/gpr-docker-publish-example'
73+ DOCKERHUB_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
74+ env :
75+ REGISTRY_TOKEN : ${{ secrets.DOCKERHUB_PAT }}
7576
7677 # This second step is illustrative and shows how to reference the
7778 # output variables. This is completely optional.
96972. `tag` : a custom tag you wish to assign to the image.
97983. `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.
9899Why? 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
100+ 4. `DOCKERHUB_USERNAME` : required when `DOCKERHUB_REPOSITORY` set to true.
99101
100102# # Outputs
101103
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ inputs:
2323 dockerhub_repository :
2424 description : Optional input to push image to dockerhub repository instead of GPR.
2525 required : false
26+ dockerhub_username :
27+ description : Required if dockerhub_repository set to true.
28+ required : false
2629outputs :
2730 IMAGE_SHA_NAME :
2831 description : name of the Docker Image including the tag
Original file line number Diff line number Diff line change 77set -e
88
99# check inputs
10- if [[ -z " $GITHUB_TOKEN " ]]; then
11- echo " You must supply the environment variable GITHUB_TOKEN ."
10+ if [[ -z " $REGISTRY_TOKEN " ]]; then
11+ echo " You must supply the environment variable REGISTRY_TOKEN ."
1212 exit 1
1313fi
1414
3333if [[ -z " $INPUT_DOCKERHUB_REPOSITORY " ]]; then
3434 DOCKER_REGISTRY=docker.pkg.github.com
3535 BASE_NAME=" ${DOCKER_REGISTRY} /${GITHUB_REPOSITORY} /${INPUT_IMAGE_NAME} "
36+ # send credentials through stdin (it is more secure)
37+ user=$( curl -s -H " Authorization: token ${REGISTRY_TOKEN} " https://api.github.com/user | jq -r .login)
38+ # lowercase the username
39+ username=" $( echo ${user} | tr " [:upper:]" " [:lower:]" ) "
3640else
41+ if [ -z " $INPUT_DOCKERHUB_USERNAME " ]
42+ then
43+ echo " If you use Docker Hub as repository please provide your username as DOCKERHUB_USERNAME."
44+ exit 1
45+ fi
46+ username=" ${INPUT_DOCKERHUB_USERNAME} "
3747 BASE_NAME=" ${INPUT_DOCKERHUB_REPOSITORY} "
3848fi
3949
40- # send credentials through stdin (it is more secure)
41- user=$( curl -s -H " Authorization: token ${GITHUB_TOKEN} " https://api.github.com/user | jq -r .login)
42- # lowercase the username
43- username=" $( echo ${user} | tr " [:upper:]" " [:lower:]" ) "
44- echo ${GITHUB_TOKEN} | docker login -u " ${username} " --password-stdin ${DOCKER_REGISTRY}
50+
51+ echo ${REGISTRY_TOKEN} | docker login -u " ${username} " --password-stdin ${DOCKER_REGISTRY}
4552
4653# Set Local Variables
4754shortSHA=$( echo " ${GITHUB_SHA} " | cut -c1-12)
You can’t perform that action at this time.
0 commit comments