This repository was archived by the owner on Dec 9, 2022. It is now read-only.
File tree 6 files changed +50
-44
lines changed
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
2
2
on : push
3
3
4
4
jobs :
7
7
steps :
8
8
9
9
- name : Copy Repo Files
10
- uses : actions/checkout@master
11
-
10
+ uses : actions/checkout@v1
11
+ with :
12
+ fetch-depth : 1
12
13
- name : Publish Docker Image to GPR
13
- uses : machine-learning-apps /gpr-docker-publish@master
14
+ uses : saubermacherag /gpr-docker-publish@master
14
15
with :
15
16
IMAGE_NAME : ' test-docker-action-v2'
16
17
TAG : ' my-optional-tag-name'
17
18
DOCKERFILE_PATH : ' Dockerfile'
18
19
BUILD_CONTEXT : ' .'
19
20
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:
60
60
DOCKERFILE_PATH : ' argo/gpu.Dockerfile'
61
61
BUILD_CONTEXT : ' argo/'
62
62
env :
63
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
63
+ REGISTRY_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64
64
65
65
# To access another docker registry like dockerhub you'll have to add `DOCKERHUB_UERNAME` and `DOCKERHUB_PAT` in github secrets.
66
66
- name : Build and Publish Docker image to Dockerhub instead of GPR
67
67
uses : saubermacherag/gpr-docker-publish@master
68
68
with :
69
- USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
70
- PASSWORD : ${{ secrets.DOCKERHUB_PAT }}
71
69
IMAGE_TAG : ' v0.0'
72
70
DOCKERFILE_PATH : ' .github/docker/Dockerfile'
73
71
BUILD_CONTEXT : ' ./'
74
72
DOCKERHUB_REPOSITORY : ' pinkrobin/gpr-docker-publish-example'
73
+ DOCKERHUB_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
74
+ env :
75
+ REGISTRY_TOKEN : ${{ secrets.DOCKERHUB_PAT }}
75
76
76
77
# This second step is illustrative and shows how to reference the
77
78
# output variables. This is completely optional.
96
97
2. `tag` : a custom tag you wish to assign to the image.
97
98
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.
98
99
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
100
+ 4. `DOCKERHUB_USERNAME` : required when `DOCKERHUB_REPOSITORY` set to true.
99
101
100
102
# # Outputs
101
103
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ inputs:
23
23
dockerhub_repository :
24
24
description : Optional input to push image to dockerhub repository instead of GPR.
25
25
required : false
26
+ dockerhub_username :
27
+ description : Required if dockerhub_repository set to true.
28
+ required : false
26
29
outputs :
27
30
IMAGE_SHA_NAME :
28
31
description : name of the Docker Image including the tag
Original file line number Diff line number Diff line change 7
7
set -e
8
8
9
9
# 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 ."
12
12
exit 1
13
13
fi
14
14
33
33
if [[ -z " $INPUT_DOCKERHUB_REPOSITORY " ]]; then
34
34
DOCKER_REGISTRY=docker.pkg.github.com
35
35
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:]" ) "
36
40
else
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} "
37
47
BASE_NAME=" ${INPUT_DOCKERHUB_REPOSITORY} "
38
48
fi
39
49
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}
45
52
46
53
# Set Local Variables
47
54
shortSHA=$( echo " ${GITHUB_SHA} " | cut -c1-12)
You can’t perform that action at this time.
0 commit comments