From 1a2fe3ecd71115c83f1ed5b6b494ab26b7bb6226 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Thu, 25 Aug 2022 13:55:16 -0400 Subject: [PATCH 1/8] adding uninstall functionality and HELM ACTION option --- action.yaml | 6 ++++++ deploy.sh | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 4ebf0af..c8733ae 100644 --- a/action.yaml +++ b/action.yaml @@ -33,6 +33,10 @@ inputs: name: description: 'Name of the helm deploy.' required: true + action: + description: 'Specify whether you want to install or uninstall the target helm chart' + required: false + default: 'install' chart-path: description: 'The path of the chart.' required: false @@ -57,6 +61,7 @@ inputs: atomic: description: 'Add the --atomic flag to rollback on failure' required: false + runs: using: 'docker' image: 'docker://bitovi/deploy-eks-helm:v1.0.3' @@ -77,3 +82,4 @@ runs: HELM_WAIT: ${{ inputs.helm-wait }} PLUGINS_LIST: ${{ inputs.plugins }} HELM_ATOMIC: ${{ inputs.atomic }} + HELM_ACTION: ${{ inputs.action }} diff --git a/deploy.sh b/deploy.sh index 1c36209..2b367cb 100644 --- a/deploy.sh +++ b/deploy.sh @@ -53,8 +53,17 @@ if [ -n "${HELM_REPOSITORY}" ]; then fi fi -# Upgrade or install the chart. This does it all. -HELM_COMMAND="helm upgrade --install --timeout ${TIMEOUT}" +if [ "${HELM_ACTION}" == "install" ]; then + # Upgrade or install the chart. This does it all. + HELM_COMMAND="helm upgrade --install --timeout ${TIMEOUT}" + +elif [ "${HELM_ACTION}" == "uninstall" ]; then + HELM_COMMAND="helm uninstall --timeout ${TIMEOUT}" + +else + echo "ERROR: HELM_ACTION specified doesn't exist in this context. Please use 'install' or 'uninstall'" + exit 2 +fi # If we should wait, then do so if [ -n "${HELM_WAIT}" ]; then From e8421cca6fc0491f2eb7447d35e424defc79a178 Mon Sep 17 00:00:00 2001 From: Phil Henning Date: Thu, 25 Aug 2022 14:59:11 -0400 Subject: [PATCH 2/8] Update action.yaml --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index c8733ae..b22112b 100644 --- a/action.yaml +++ b/action.yaml @@ -64,7 +64,7 @@ inputs: runs: using: 'docker' - image: 'docker://bitovi/deploy-eks-helm:v1.0.3' + image: 'docker://bitovi/deploy-eks-helm:uninstall' env: AWS_REGION: ${{ inputs.aws-region }} AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} From 9e45637e85c10b4a62bf41c08bbc397c3b5c3ee0 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Fri, 26 Aug 2022 08:47:28 -0400 Subject: [PATCH 3/8] Adding check for uninstall (-f) --- deploy.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index 2b367cb..70b8ce3 100644 --- a/deploy.sh +++ b/deploy.sh @@ -76,10 +76,13 @@ if [ -n "${HELM_ATOMIC}" ]; then fi # Set paramaters -for config_file in ${DEPLOY_CONFIG_FILES//,/ } -do - HELM_COMMAND="${HELM_COMMAND} -f ${config_file}" -done +if [ "${HELM_ACTION}" != "uninstall" ]; then + for config_file in ${DEPLOY_CONFIG_FILES//,/ } + do + HELM_COMMAND="${HELM_COMMAND} -f ${config_file}" + done +fi + if [ -n "$DEPLOY_NAMESPACE" ]; then HELM_COMMAND="${HELM_COMMAND} -n ${DEPLOY_NAMESPACE}" fi From 77eabeee7fee22b3678fa045eff3e1b9bebd9732 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Fri, 26 Aug 2022 09:02:29 -0400 Subject: [PATCH 4/8] updating action image --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index b22112b..93a02bb 100644 --- a/action.yaml +++ b/action.yaml @@ -64,7 +64,7 @@ inputs: runs: using: 'docker' - image: 'docker://bitovi/deploy-eks-helm:uninstall' + image: 'docker://bitovi/deploy-eks-helm:pr-uninstall' env: AWS_REGION: ${{ inputs.aws-region }} AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} From 10b8eda2e56eeb1ed1ffd440c9f374e9690a75ad Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Fri, 26 Aug 2022 09:21:00 -0400 Subject: [PATCH 5/8] moving parameters to install block --- deploy.sh | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/deploy.sh b/deploy.sh index 70b8ce3..5a1f8f4 100644 --- a/deploy.sh +++ b/deploy.sh @@ -57,38 +57,36 @@ if [ "${HELM_ACTION}" == "install" ]; then # Upgrade or install the chart. This does it all. HELM_COMMAND="helm upgrade --install --timeout ${TIMEOUT}" -elif [ "${HELM_ACTION}" == "uninstall" ]; then - HELM_COMMAND="helm uninstall --timeout ${TIMEOUT}" - -else - echo "ERROR: HELM_ACTION specified doesn't exist in this context. Please use 'install' or 'uninstall'" - exit 2 -fi - -# If we should wait, then do so -if [ -n "${HELM_WAIT}" ]; then - HELM_COMMAND="${HELM_COMMAND} --wait" -fi + # If we should wait, then do so + if [ -n "${HELM_WAIT}" ]; then + HELM_COMMAND="${HELM_COMMAND} --wait" + fi -# Add atomic flag -if [ -n "${HELM_ATOMIC}" ]; then - HELM_COMMAND="${HELM_COMMAND} --atomic" -fi + # Add atomic flag + if [ -n "${HELM_ATOMIC}" ]; then + HELM_COMMAND="${HELM_COMMAND} --atomic" + fi -# Set paramaters -if [ "${HELM_ACTION}" != "uninstall" ]; then for config_file in ${DEPLOY_CONFIG_FILES//,/ } do HELM_COMMAND="${HELM_COMMAND} -f ${config_file}" done + + if [ -n "$DEPLOY_VALUES" ]; then + HELM_COMMAND="${HELM_COMMAND} --set ${DEPLOY_VALUES}" + fi + +elif [ "${HELM_ACTION}" == "uninstall" ]; then + HELM_COMMAND="helm uninstall --timeout ${TIMEOUT}" + +else + echo "ERROR: HELM_ACTION specified doesn't exist in this context. Please use 'install' or 'uninstall'" + exit 2 fi if [ -n "$DEPLOY_NAMESPACE" ]; then HELM_COMMAND="${HELM_COMMAND} -n ${DEPLOY_NAMESPACE}" fi -if [ -n "$DEPLOY_VALUES" ]; then - HELM_COMMAND="${HELM_COMMAND} --set ${DEPLOY_VALUES}" -fi # Execute Commands HELM_COMMAND="${HELM_COMMAND} ${DEPLOY_NAME} ${DEPLOY_CHART_PATH}" From ca59a9a4b2f00b32e312f14bc908dae1b959c4aa Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Fri, 26 Aug 2022 09:38:41 -0400 Subject: [PATCH 6/8] breaking chart out of command (uninstall) --- deploy.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 5a1f8f4..26387f6 100644 --- a/deploy.sh +++ b/deploy.sh @@ -89,6 +89,11 @@ if [ -n "$DEPLOY_NAMESPACE" ]; then fi # Execute Commands -HELM_COMMAND="${HELM_COMMAND} ${DEPLOY_NAME} ${DEPLOY_CHART_PATH}" +HELM_COMMAND="${HELM_COMMAND} ${DEPLOY_NAME}" + +if [ "${HELM_ACTION}" == "install" ]; then + HELM_COMMAND="${HELM_COMMAND} ${DEPLOY_CHART_PATH}" +fi + echo "Executing: ${HELM_COMMAND}" ${HELM_COMMAND} From d6f0024f2844d6645d0c02080a005e564090ecd9 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Fri, 26 Aug 2022 10:06:54 -0400 Subject: [PATCH 7/8] updating image version --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 93a02bb..c8733ae 100644 --- a/action.yaml +++ b/action.yaml @@ -64,7 +64,7 @@ inputs: runs: using: 'docker' - image: 'docker://bitovi/deploy-eks-helm:pr-uninstall' + image: 'docker://bitovi/deploy-eks-helm:v1.0.3' env: AWS_REGION: ${{ inputs.aws-region }} AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} From 379671e3751f285f14d0c40653a3bc561e449171 Mon Sep 17 00:00:00 2001 From: Phil Henning Date: Fri, 26 Aug 2022 10:08:14 -0400 Subject: [PATCH 8/8] Update action.yaml --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index c8733ae..a7428d1 100644 --- a/action.yaml +++ b/action.yaml @@ -64,7 +64,7 @@ inputs: runs: using: 'docker' - image: 'docker://bitovi/deploy-eks-helm:v1.0.3' + image: 'docker://bitovi/deploy-eks-helm:v1.0.4' env: AWS_REGION: ${{ inputs.aws-region }} AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }}