Skip to content

Commit 707d2e9

Browse files
authored
Merge pull request #1 from roromix/master
Give the ability to use docker hub private image
2 parents e929a93 + dc034c8 commit 707d2e9

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ portainer终结点id,默认是1,即第一个,一般为localhost
2323
**required** name of stack <br>
2424
服务栈的名称,会在stacks列表里显示
2525

26+
## registry
27+
address of registry, like: myregistry.example.com (leave empty for Docker Hub) <br>
28+
2629
## imagename
2730
**required** name of pull image, like: mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine <br>
2831
将会进行拉取镜像的镜像名
@@ -54,7 +57,8 @@ The following will delete it if same name stack is existed.
5457
password: ${{ secrets.PORTAINER_PASSWORD }}
5558
endpointId: 1
5659
stackname: dotnet_test
57-
imagename: mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
60+
registry: mcr.microsoft.com
61+
imagename: dotnet/core/aspnet:3.1-alpine
5862
docker_compose: |
5963
version: "2"
6064
services:

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ inputs:
2121
stackname:
2222
description: 'name of stack, lowercase'
2323
required: true
24+
registry:
25+
description: 'image registry'
26+
required: false
27+
default: ''
2428
imagename:
2529
description: 'deploy image name'
2630
required: true

entrypoint.sh

+4-11
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,9 @@ fi
3131
#pull image
3232
#拉取镜像
3333
echo "pull image: $INPUT_IMAGENAME"
34-
registry=$(echo "$INPUT_IMAGENAME" | awk -F'/' '{print $1}')
35-
if [[ "$registry" =~ "." ]]
36-
then
37-
base64Registry=$(echo "{\"serveraddress\":\"$registry\"}" | base64)
38-
curl --location --request POST ''${INPUT_SERVERURL}'/api/endpoints/'$INPUT_ENDPOINTID'/docker/images/create?fromImage='$INPUT_IMAGENAME'' \
39-
-H "Authorization: Bearer $token" -H "X-Registry-Auth: $base64Registry"
40-
else
41-
curl --location --request POST ''${INPUT_SERVERURL}'/api/endpoints/'$INPUT_ENDPOINTID'/docker/images/create?fromImage='$INPUT_IMAGENAME'' \
42-
-H "Authorization: Bearer $token"
43-
fi
34+
base64Registry=$(echo "{\"serveraddress\":\"$INPUT_REGISTRY\"}" | base64)
35+
curl --location --request POST ''${INPUT_SERVERURL}'/api/endpoints/'$INPUT_ENDPOINTID'/docker/images/create?fromImage='$INPUT_IMAGENAME'' \
36+
-H "Authorization: Bearer $token" -H "X-Registry-Auth: $base64Registry"
4437

4538

4639

@@ -107,4 +100,4 @@ if [ "$message" != "null" ]; then
107100
echo "create failed: $message"
108101
exit 1
109102
fi
110-
exit 0
103+
exit 0

0 commit comments

Comments
 (0)