Skip to content

Commit

Permalink
Merge pull request #25 from whoan/tag-image-as-a-separate-step
Browse files Browse the repository at this point in the history
Tag image as a separate step (#24)
  • Loading branch information
whoan authored Mar 13, 2020
2 parents 8cc878c + 94b7bc1 commit 154caee
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,31 @@ _get_full_image_name() {
echo ${INPUT_REGISTRY:+$INPUT_REGISTRY/}${INPUT_IMAGE_NAME}
}

_tag_and_push() {
_tag() {
local tag
tag="${1:?You must provide a tag}"
docker tag $dummy_image_name "$(_get_full_image_name):$tag"
}

_push() {
local tag
tag="${1:?You must provide a tag}"
docker push "$(_get_full_image_name):$tag"
}

_push_git_tag() {
[[ "$GITHUB_REF" =~ /tags/ ]] || return 0
local git_tag=${GITHUB_REF##*/tags/}
echo -e "\nPushing git tag: $git_tag"
_tag_and_push $git_tag
_tag $git_tag
_push $git_tag
}

_push_image_tags() {
local tag
for tag in "${INPUT_IMAGE_TAG[@]}"; do
echo "Pushing tag: $tag"
_tag_and_push $tag
echo "Pushing: $tag"
_push $tag
done
if [ "$INPUT_PUSH_GIT_TAG" = true ]; then
_push_git_tag
Expand Down Expand Up @@ -128,6 +134,15 @@ build_image() {
set +x
}

tag_image() {
echo -e "\n[Action Step] Tagging image..."
local tag
for tag in "${INPUT_IMAGE_TAG[@]}"; do
echo "Tagging: $tag"
_tag $tag
done
}

push_image_and_stages() {
if [ "$INPUT_PUSH_IMAGE_AND_STAGES" != true ]; then
return
Expand Down Expand Up @@ -157,5 +172,6 @@ check_required_input
login_to_registry
pull_cached_stages
build_image
tag_image
push_image_and_stages
logout_from_registry

0 comments on commit 154caee

Please sign in to comment.