Skip to content

Commit

Permalink
v0.2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbam committed Mar 15, 2021
1 parent ffec71b commit 16b38ce
Show file tree
Hide file tree
Showing 4 changed files with 41 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 pushes the container"
LABEL "com.github.actions.icon"="anchor"
LABEL "com.github.actions.color"="blue"

LABEL version=v0.2.16
LABEL version=v0.2.17
LABEL repository="https://github.com/opspresso/action-docker"
LABEL maintainer="Jungyoul Yu <me@nalbam.com>"
LABEL homepage="https://opspresso.com/"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.2.16
v0.2.17
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branding:

runs:
using: docker
image: docker://opspresso/action-docker:v0.2.16
image: docker://opspresso/action-docker:v0.2.17

outputs:
TAG_NAME:
Expand Down
50 changes: 38 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,35 @@ REPOSITORY=${GITHUB_REPOSITORY}
USERNAME=${USERNAME:-$GITHUB_ACTOR}
REPONAME=$(echo "${REPOSITORY}" | cut -d'/' -f2)

_error() {
echo -e "$1"
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
_echo "- $@" 1
if [ "${LOOSE_ERROR}" == "true" ]; then
exit 0
else
Expand Down Expand Up @@ -63,21 +89,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 +141,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 @@ -168,17 +194,17 @@ text
EOF

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

echo "aws ecr get-login-password ${AWS_ACCOUNT_ID} ${AWS_REGION}"
_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 --output json | 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 @@ -189,7 +215,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 16b38ce

Please sign in to comment.