Skip to content

Commit

Permalink
Merge pull request #8 from bitovi/uninstall
Browse files Browse the repository at this point in the history
adding uninstall functionality and HELM ACTION option
  • Loading branch information
PhillypHenning authored Aug 26, 2022
2 parents 789f647 + 379671e commit 343c9f7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
8 changes: 7 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -57,9 +61,10 @@ 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'
image: 'docker://bitovi/deploy-eks-helm:v1.0.4'
env:
AWS_REGION: ${{ inputs.aws-region }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }}
Expand All @@ -77,3 +82,4 @@ runs:
HELM_WAIT: ${{ inputs.helm-wait }}
PLUGINS_LIST: ${{ inputs.plugins }}
HELM_ATOMIC: ${{ inputs.atomic }}
HELM_ACTION: ${{ inputs.action }}
51 changes: 33 additions & 18 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,47 @@ 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}"

# 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"
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

# Set paramaters
for config_file in ${DEPLOY_CONFIG_FILES//,/ }
do
HELM_COMMAND="${HELM_COMMAND} -f ${config_file}"
done
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}"
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}

0 comments on commit 343c9f7

Please sign in to comment.