From ee5987d1843ebec60e7347707b8efd021092113b Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Mon, 13 Jan 2020 09:01:05 +0900 Subject: [PATCH] feat: Add tagOverwrite option --- action.yml | 4 ++++ entrypoint.sh | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 250d6f6..2e04b65 100644 --- a/action.yml +++ b/action.yml @@ -35,3 +35,7 @@ inputs: tagMessage: description: 'Set tag message' required: false + tagOverwrite: + description: 'Enable overwriting tag' + required: false + default: false diff --git a/entrypoint.sh b/entrypoint.sh index 2e33dde..b2b4c70 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -144,13 +144,20 @@ fi if [[ -n "${INPUT_TAGNAME}" ]]; then print_info "Tag name: ${INPUT_TAGNAME}" + print_info "Tag message: ${INPUT_TAGMESSAGE}" + print_info "Tag overwrite: ${INPUT_TAGOVERWRITE}" if [[ -n "${INPUT_TAGMESSAGE}" ]]; then - print_info "Tag message: ${INPUT_TAGMESSAGE}" - git tag "${INPUT_TAGNAME}" -m "${INPUT_TAGMESSAGE}" + GIT_TAG_MESSAGE="${INPUT_TAGMESSAGE}" else - git tag "${INPUT_TAGNAME}" + GIT_TAG_MESSAGE="Deployment ${INPUT_TAGNAME}" fi - git push origin "${INPUT_TAGNAME}" + if [[ "${INPUT_TAGOVERWRITE}" == "true" ]]; then + GIT_TAG_OPTION="--force" + else + GIT_TAG_OPTION="" + fi + git tag "${GIT_TAG_OPTION}" -a "${INPUT_TAGNAME}" -m "${GIT_TAG_MESSAGE}" + git push "${GIT_TAG_OPTION}" origin "${INPUT_TAGNAME}" fi print_info "${GITHUB_SHA} was successfully deployed"