Skip to content

Commit 1311c8b

Browse files
author
Timur Galeev
committed
Update command run
1 parent 2962d6e commit 1311c8b

4 files changed

Lines changed: 46 additions & 15 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LABEL "com.github.actions.description"="build, tag and push container"
55
LABEL "com.github.actions.icon"="anchor"
66
LABEL "com.github.actions.color"="blue"
77

8-
LABEL version=v0.2.4
8+
LABEL version=v0.3.1
99
LABEL repository="https://github.com/timzu/act-docker"
1010
LABEL maintainer="Timur Galeev <timur_galeev@outlook.com>"
1111

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2.4
1+
v0.3.1

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ branding:
88

99
runs:
1010
using: docker
11-
image: docker://timzu/act-docker:v0.2.4
11+
image: docker://timzu/act-docker:v0.3.1
1212

1313
outputs:
1414
TAG_NAME:
15-
description: "Your Docker Tag name."
15+
description: "Docker Tag"

entrypoint.sh

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,35 @@ REPOSITORY=${GITHUB_REPOSITORY}
77
USERNAME=${USERNAME:-$GITHUB_ACTOR}
88
REPONAME=$(echo "${REPOSITORY}" | cut -d'/' -f2)
99

10+
command -v tput > /dev/null && TPUT=true
11+
12+
_echo() {
13+
if [ "${TPUT}" != "" ] && [ "$2" != "" ]; then
14+
echo -e "$(tput setaf $2)$1$(tput sgr0)"
15+
else
16+
echo -e "$1"
17+
fi
18+
}
19+
20+
_result() {
21+
echo
22+
_echo "# $@" 4
23+
}
24+
25+
_command() {
26+
echo
27+
_echo "$ $@" 3
28+
}
29+
30+
_success() {
31+
echo
32+
_echo "+ $@" 2
33+
exit 0
34+
}
35+
1036
_error() {
11-
echo -e "$1"
37+
echo
38+
_echo "- $@" 1
1239

1340
if [ "${LOOSE_ERROR}" == "true" ]; then
1441
exit 0
@@ -63,21 +90,21 @@ _docker_tag() {
6390
}
6491

6592
_docker_push() {
66-
echo "docker build ${DOCKER_BUILD_ARGS} -t ${IMAGE_URI}:${TAG_NAME} -f ${DOCKERFILE} ${BUILD_PATH}"
93+
_command "docker build ${DOCKER_BUILD_ARGS} -t ${IMAGE_URI}:${TAG_NAME} -f ${DOCKERFILE} ${BUILD_PATH}"
6794
docker build ${DOCKER_BUILD_ARGS} -t ${IMAGE_URI}:${TAG_NAME} -f ${DOCKERFILE} ${BUILD_PATH}
6895

6996
_error_check
7097

71-
echo "docker push ${IMAGE_URI}:${TAG_NAME}"
98+
_command "docker push ${IMAGE_URI}:${TAG_NAME}"
7299
docker push ${IMAGE_URI}:${TAG_NAME}
73100

74101
_error_check
75102

76103
if [ "${LATEST}" == "true" ]; then
77-
echo "docker tag ${IMAGE_URI}:latest"
104+
_command "docker tag ${IMAGE_URI}:latest"
78105
docker tag ${IMAGE_URI}:${TAG_NAME} ${IMAGE_URI}:latest
79106

80-
echo "docker push ${IMAGE_URI}:latest"
107+
_command "docker push ${IMAGE_URI}:latest"
81108
docker push ${IMAGE_URI}:latest
82109
fi
83110
}
@@ -115,14 +142,14 @@ _docker_pre() {
115142
_docker() {
116143
_docker_pre
117144

118-
echo "docker login ${REGISTRY} -u ${USERNAME}"
145+
_command "docker login ${REGISTRY} -u ${USERNAME}"
119146
echo ${PASSWORD} | docker login ${REGISTRY} -u ${USERNAME} --password-stdin
120147

121148
_error_check
122149

123150
_docker_push
124151

125-
echo "docker logout"
152+
_command "docker logout"
126153
docker logout
127154
}
128155

@@ -167,14 +194,18 @@ ${AWS_REGION}
167194
text
168195
EOF
169196

170-
echo "aws ecr get-login --no-include-email"
171-
aws ecr get-login --no-include-email | sh
197+
# https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login.html
198+
# _command "aws ecr get-login --no-include-email"
199+
# aws ecr get-login --no-include-email | sh
200+
201+
_command "aws ecr get-login-password ${AWS_ACCOUNT_ID} ${AWS_REGION}"
202+
aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/
172203

173204
_error_check
174205

175206
COUNT=$(aws ecr describe-repositories | jq '.repositories[] | .repositoryName' | grep "\"${IMAGE_NAME}\"" | wc -l | xargs)
176207
if [ "x${COUNT}" == "x0" ]; then
177-
echo "aws ecr create-repository ${IMAGE_NAME}"
208+
_command "aws ecr create-repository ${IMAGE_NAME}"
178209
aws ecr create-repository --repository-name ${IMAGE_NAME} --image-tag-mutability ${IMAGE_TAG_MUTABILITY}
179210
fi
180211

@@ -185,7 +216,7 @@ if [ -z "${CMD}" ]; then
185216
CMD="--docker"
186217
fi
187218

188-
echo "[${CMD:2}] start..."
219+
_result "[${CMD:2}] start..."
189220

190221
case "${CMD:2}" in
191222
docker)

0 commit comments

Comments
 (0)