forked from jobtome-labs/ci-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helm-publish.yml
58 lines (43 loc) · 1.36 KB
/
helm-publish.yml
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
helm:publish:
image: devth/helm:v3.1.1
stage: push
script:
- |
# CHECKING PHASE
for var in "GOOGLE_KEY" "BUCKET_NAME" "GOOGLE_PROJECT"; do
if [ -z "${!var}" ]; then
echo
echo "-> [WARNING] Missing '${var}' variable!"
echo
exit 1
fi
done
# ACTIVATION PHASE
echo "${GOOGLE_KEY}" > /tmp/key.json
gcloud auth activate-service-account --key-file /tmp/key.json
gcloud config set project "${GOOGLE_PROJECT}"
echo
echo "-> Google project '${GOOGLE_PROJECT}' configured!"
echo
# DEPLOY PHASE
COMMAND_TO_RUN=( gsutil )
# Check if unset (but allow empty string)
if [ -z "${BUCKET_PATH+x}" ]; then
BUCKET_PATH="charts"
fi
if [ -n "${BUCKET_HEADERS}" ]; then
echo
echo "-> Setting '${BUCKET_HEADERS}' headers!"
echo
COMMAND_TO_RUN+=( -h "${BUCKET_HEADERS}" )
fi
BUCKET_FULL_PATH="gs:/$(echo "/${BUCKET_NAME}/${BUCKET_PATH}/" | tr -s /)"
"${COMMAND_TO_RUN[@]} cp ${BUCKET_FULL_PATH}index.yaml /tmp/index.yaml"
helm package .
helm repo index . --merge /tmp/index.yaml
"${COMMAND_TO_RUN[@]} cp ./index.yaml ${BUCKET_FULL_PATH}index.yaml"
"${COMMAND_TO_RUN[@]} cp ./*.tgz* ${BUCKET_FULL_PATH}"
only:
- /^v.+$/i
except:
- branches