-
Notifications
You must be signed in to change notification settings - Fork 2
/
helm-deploy.sh
executable file
·58 lines (48 loc) · 1.93 KB
/
helm-deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#*******************************************************************************
# Copyright (c) 2024 Eclipse Foundation and others.
# This program and the accompanying materials are made available
# under the terms of the Eclipse Public License 2.0
# which is available at http://www.eclipse.org/legal/epl-v20.html
# SPDX-License-Identifier: EPL-2.0
#*******************************************************************************
# Bash strict-mode
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'
SCRIPT_FOLDER="$(dirname "$(readlink -f "${0}")")"
ROOT_DIR="${SCRIPT_FOLDER}"
release_name_staging="nexus-staging"
release_name_production="nexus-production"
chart_name="nexus"
namespace="repo-eclipse-org"
environment="${1:-}"
image_tag="${2:-}" #optional
# check that environment is not empty
if [[ -z "${environment}" ]]; then
printf "ERROR: an environment ('staging' or 'production') must be given.\n"
exit 1
fi
if [[ "${environment}" == "staging" ]]; then
values_file="${ROOT_DIR}/charts/${chart_name}/values-staging.yaml"
release_name="${release_name_staging}"
elif [[ "${environment}" == "production" ]]; then
values_file="${ROOT_DIR}/charts/${chart_name}/values.yaml"
release_name="${release_name_production}"
else
printf "ERROR: Unknown environment. Only 'staging' or 'production' are supported.\n"
exit 1
fi
if helm list -n "${namespace}" | grep "${release_name}" > /dev/null; then
echo "Found installed Helm chart for release name '${release_name}'. Upgrading..."
action="upgrade"
else
echo "Found no installed Helm chart for release name '${release_name}'. Installing..."
action="install"
fi
if [[ -z "${image_tag}" ]]; then
helm "${action}" "${release_name}" "${ROOT_DIR}/charts/${chart_name}" -f "${values_file}" --namespace "${namespace}"
else
helm "${action}" "${release_name}" "${ROOT_DIR}/charts/${chart_name}" -f "${values_file}" --set image.tag="${image_tag}" --namespace "${namespace}"
fi