Skip to content

Commit

Permalink
v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbam committed Feb 24, 2022
1 parent 357a127 commit 233ac52
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 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.3.9
LABEL version=v0.4.0
LABEL repository="https://github.com/opspresso/action-docker"
LABEL maintainer="Jungyoul Yu <[email protected]>"
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.3.9
v0.4.0
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.3.9
image: docker://opspresso/action-docker:v0.4.0

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

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

_echo() {
if [ "${TPUT}" != "" ] && [ "$2" != "" ]; then
Expand Down Expand Up @@ -88,6 +88,19 @@ _docker_tag() {
fi
}

_docker_file() {
if [ -z "${DOCKERFILE}" ]; then
DOCKERFILE="Dockerfile"
if [ ! -f ${DOCKERFILE} ]; then
if [ ! -z "${BASE_IMAGE}" ]; then
echo "FROM ${BASE_IMAGE}:${TAG_NAME}" >${DOCKERFILE}
else
_error "${DOCKERFILE} not found."
fi
fi
fi
}

_docker_build() {
_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}
Expand Down Expand Up @@ -173,6 +186,8 @@ _docker_buildx() {
}

_docker_pre() {
_docker_tag

if [ -z "${USERNAME}" ]; then
_error "USERNAME is not set."
fi
Expand All @@ -185,9 +200,7 @@ _docker_pre() {
BUILD_PATH="."
fi

if [ -z "${DOCKERFILE}" ]; then
DOCKERFILE="Dockerfile"
fi
_docker_file

if [ -z "${IMAGE_NAME}" ]; then
if [ "${REGISTRY}" == "docker.pkg.github.com" ]; then
Expand All @@ -207,8 +220,6 @@ _docker_pre() {
IMAGE_URI="${REGISTRY}/${IMAGE_NAME}"
fi
fi

_docker_tag
}

_docker() {
Expand Down Expand Up @@ -237,6 +248,8 @@ _docker() {
_docker_ecr_pre() {
_aws_pre

_docker_tag

if [ -z "${AWS_ACCOUNT_ID}" ]; then
AWS_ACCOUNT_ID="$(aws sts get-caller-identity --output json | jq '.Account' -r)"
fi
Expand All @@ -245,9 +258,7 @@ _docker_ecr_pre() {
BUILD_PATH="."
fi

if [ -z "${DOCKERFILE}" ]; then
DOCKERFILE="Dockerfile"
fi
_docker_file

if [ -z "${REGISTRY}" ]; then
REGISTRY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"
Expand All @@ -267,8 +278,6 @@ _docker_ecr_pre() {
IMAGE_URI="${REGISTRY}/${IMAGE_NAME}"
fi

_docker_tag

if [ "${IMAGE_TAG_MUTABILITY}" != "IMMUTABLE" ]; then
IMAGE_TAG_MUTABILITY="MUTABLE"
fi
Expand All @@ -278,7 +287,7 @@ _docker_ecr() {
_docker_ecr_pre

# aws credentials
aws configure <<-EOF > /dev/null 2>&1
aws configure <<-EOF >/dev/null 2>&1
${AWS_ACCESS_KEY_ID}
${AWS_SECRET_ACCESS_KEY}
${AWS_REGION}
Expand Down Expand Up @@ -328,14 +337,15 @@ fi
_result "[${CMD:2}] start..."

case "${CMD:2}" in
docker)
_docker
;;
ecr)
_docker_ecr
;;
*)
_error
docker)
_docker
;;
ecr)
_docker_ecr
;;
*)
_error
;;
esac

echo ::set-output name=TAG_NAME::${TAG_NAME}

0 comments on commit 233ac52

Please sign in to comment.