Skip to content

Commit

Permalink
Update command run
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Galeev committed Mar 20, 2021
1 parent 2962d6e commit 1311c8b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LABEL "com.github.actions.description"="build, tag and push container"
LABEL "com.github.actions.icon"="anchor"
LABEL "com.github.actions.color"="blue"

LABEL version=v0.2.4
LABEL version=v0.3.1
LABEL repository="https://github.com/timzu/act-docker"
LABEL maintainer="Timur Galeev <[email protected]>"

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.2.4
v0.3.1
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ branding:

runs:
using: docker
image: docker://timzu/act-docker:v0.2.4
image: docker://timzu/act-docker:v0.3.1

outputs:
TAG_NAME:
description: "Your Docker Tag name."
description: "Docker Tag"
53 changes: 42 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,35 @@ REPOSITORY=${GITHUB_REPOSITORY}
USERNAME=${USERNAME:-$GITHUB_ACTOR}
REPONAME=$(echo "${REPOSITORY}" | cut -d'/' -f2)

command -v tput > /dev/null && TPUT=true

_echo() {
if [ "${TPUT}" != "" ] && [ "$2" != "" ]; then
echo -e "$(tput setaf $2)$1$(tput sgr0)"
else
echo -e "$1"
fi
}

_result() {
echo
_echo "# $@" 4
}

_command() {
echo
_echo "$ $@" 3
}

_success() {
echo
_echo "+ $@" 2
exit 0
}

_error() {
echo -e "$1"
echo
_echo "- $@" 1

if [ "${LOOSE_ERROR}" == "true" ]; then
exit 0
Expand Down Expand Up @@ -63,21 +90,21 @@ _docker_tag() {
}

_docker_push() {
echo "docker build ${DOCKER_BUILD_ARGS} -t ${IMAGE_URI}:${TAG_NAME} -f ${DOCKERFILE} ${BUILD_PATH}"
_command "docker build ${DOCKER_BUILD_ARGS} -t ${IMAGE_URI}:${TAG_NAME} -f ${DOCKERFILE} ${BUILD_PATH}"
docker build ${DOCKER_BUILD_ARGS} -t ${IMAGE_URI}:${TAG_NAME} -f ${DOCKERFILE} ${BUILD_PATH}

_error_check

echo "docker push ${IMAGE_URI}:${TAG_NAME}"
_command "docker push ${IMAGE_URI}:${TAG_NAME}"
docker push ${IMAGE_URI}:${TAG_NAME}

_error_check

if [ "${LATEST}" == "true" ]; then
echo "docker tag ${IMAGE_URI}:latest"
_command "docker tag ${IMAGE_URI}:latest"
docker tag ${IMAGE_URI}:${TAG_NAME} ${IMAGE_URI}:latest

echo "docker push ${IMAGE_URI}:latest"
_command "docker push ${IMAGE_URI}:latest"
docker push ${IMAGE_URI}:latest
fi
}
Expand Down Expand Up @@ -115,14 +142,14 @@ _docker_pre() {
_docker() {
_docker_pre

echo "docker login ${REGISTRY} -u ${USERNAME}"
_command "docker login ${REGISTRY} -u ${USERNAME}"
echo ${PASSWORD} | docker login ${REGISTRY} -u ${USERNAME} --password-stdin

_error_check

_docker_push

echo "docker logout"
_command "docker logout"
docker logout
}

Expand Down Expand Up @@ -167,14 +194,18 @@ ${AWS_REGION}
text
EOF

echo "aws ecr get-login --no-include-email"
aws ecr get-login --no-include-email | sh
# https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login.html
# _command "aws ecr get-login --no-include-email"
# aws ecr get-login --no-include-email | sh

_command "aws ecr get-login-password ${AWS_ACCOUNT_ID} ${AWS_REGION}"
aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/

_error_check

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

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

echo "[${CMD:2}] start..."
_result "[${CMD:2}] start..."

case "${CMD:2}" in
docker)
Expand Down

0 comments on commit 1311c8b

Please sign in to comment.