-
torgiren authored
Signed-off-by:
Marcin Fabrykowski <git@fabrykowski.pl>
Unverified6fb12bed
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
---
stages:
- upload
upload:
stage: upload
image:
name: alpine/helm
before_script:
- apk add --no-cache ca-certificates git curl yq
- helm plugin install https://github.com/chartmuseum/helm-push.git
- helm repo add --username ${CI_REGISTRY_USER} --password ${CI_REGISTRY_PASSWORD} my-repo "${CI_API_V4_URL}/projects/6/packages/helm/stable"
- helm repo update
script:
- export VERSION=$(git describe --tags)
- sed -i "s/__VERSION__/$VERSION/" chart/Chart.yaml
- helm lint chart
- helm cm-push chart my-repo
.deploy-to-git:
image: alpine
before_script:
- apk add --no-cache ca-certificates git curl yq openssh-client-default
- eval $(ssh-agent -s)
- ssh-add <(echo "$GITLAB_SSH_KEY")
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- mkdir -p ~/.ssh
- ssh-keyscan -t rsa gitlab.exphost.pl >> ~/.ssh/known_hosts
- curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl
- chmod +x /usr/local/bin/kubectl
script:
- export VERSION=$(git describe --tags)
- git clone $repo repo
- cd repo
- echo ${patch_cmd}
- eval ${patch_cmd}
- |
if [[ -n "$(git status --porcelain)" ]]; then
git add . &&
git commit -m "update by gitlab-ci" &&
git push
fi
- for try in {1..60} do
state==$(kubectl -n argocd get applications "$waitapp" -o template='{{.status.health.status}},{{.status.sync.status}},{{.spec.source.targetRevision}}');
echo $state;
[ "$state" == "Healthy,Synced,$$VERSION"] && break;
sleep 5;
done
- [ $$try -lt 60 ]
.deploy-to-git-subapp:
extends: .deploy-to-git
variables:
patch_cmd: |
values=$(yq e '.spec.source.helm.values' $yamlfile| yq e '.'"$app"'.version="'$$VERSION'"' -)
yq e -i '.spec.source.helm.values=strenv(values)' $yamlfile