-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (53 loc) · 2.02 KB
/
build-pre-release-chart.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
59
60
61
62
name: Build chart and push into registry
on:
workflow_call:
secrets:
helm_registry_username:
required: true
helm_registry_password:
required: true
inputs:
service:
required: false
type: string
default: .
jobs:
release:
name: Build and push
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build and push helm chart
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
source ./get_helm.sh
printf "%s" "${HELM_PASSWORD}" | helm registry login cr.yandex --username "${HELM_USERNAME}" --password-stdin
cd ${WORKDIR}/chart/
helm dependency build .
if [ -f sample.yaml ]; then
helm lint -f sample.yaml
else
helm lint
fi
export CHART_NAME=$(grep '^name:' Chart.yaml | cut -d' ' -f2)
export HEAD_COMMIT=$(git rev-parse --short=7 HEAD)
export CHART_VERSION=$(grep 'version:' Chart.yaml | cut -d' ' -f2)-g${HEAD_COMMIT}
echo ${CHART_VERSION}
echo "Check if chart with version ${CHART_VERSION} exist"
if (helm show chart oci://cr.yandex/crp3782d3l6o6crc3ic0/${CHART_NAME} --version ${CHART_VERSION} &> /dev/null); then
echo "The chart ${CHART_NAME} with version ${CHART_VERSION} exist, exiting"
exit 0
else
echo "Chart does not exist"
helm package . --version ${CHART_VERSION}
echo "Chart will be uploaded into registry"
helm push ${CHART_NAME}-${CHART_VERSION}.tgz oci://cr.yandex/crp3782d3l6o6crc3ic0
echo "Chart has been uploaded successfully"
fi
env:
HELM_USERNAME: ${{ secrets.helm_registry_username }}
HELM_PASSWORD: ${{ secrets.helm_registry_password }}
WORKDIR: ${{ inputs.service }}