-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
53 lines (50 loc) · 2.64 KB
/
.gitlab-ci.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
stages:
- Build
- Deploy
before_script:
- export BASE_URL=${BASE_URL:-$(echo $CI_PROJECT_URL | cut -d'/' -f1-3)}
CI-Proxy:
stage: Build
script:
- >
if [ "$CI_COMMIT_REF_NAME" == "master" ]; then
echo "Deploying $CI_COMMIT_REF_NAME"
elif [ "$CI_COMMIT_REF_NAME" == "production" ]; then
echo "Deploying $CI_COMMIT_REF_NAME"
else
echo "No Matching Environment Could Be Found"
exit 1
fi
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker build --pull --no-cache -t "$CI_REGISTRY_IMAGE/ciproxy-$CI_COMMIT_REF_NAME:$CI_COMMIT_SHA" .
- docker push "$CI_REGISTRY_IMAGE/ciproxy-$CI_COMMIT_REF_NAME:$CI_COMMIT_SHA"
CI-Proxy-Deploy:
stage: Deploy
image: crosscloudci/helm:latest
script:
- >
if [ "$CI_COMMIT_REF_NAME" == "master" ]; then
echo "Deploying $CI_COMMIT_REF_NAME"
export CIPROXY_INGRESS="devapi.cncf.ci"
export TLS="true"
export PROJECT_SEGMENT_ENV="integration"
export DEPLOYMENT_NAME="$(echo "proxy-$CI_COMMIT_REF_NAME" | cut -c 1-10)"
elif [ "$CI_COMMIT_REF_NAME" == "production" ]; then
echo "Deploying $CI_COMMIT_REF_NAME"
export CIPROXY_INGRESS="productionapi.cncf.ci"
export TLS="true"
export PROJECT_SEGMENT_ENV="production"
export DEPLOYMENT_NAME="$(echo "proxy-$CI_COMMIT_REF_NAME" | cut -c 1-10)"
else
echo "No Matching Environment Could Be Found"
exit 1
fi
- /helm/entrypoint.sh
- export KUBECONFIG=/kubeconfig
- helm repo add stable https://charts.helm.sh/stable
- helm repo add cncf http://cncf.gitlab.io/stable
- helm repo update
- helm delete db-"$DEPLOYMENT_NAME" || true
- helm install db-"$DEPLOYMENT_NAME" stable/postgresql --set postgresqlDatabase=ciproxy --set persistence.enabled=false --set service.type=ClusterIP
- export POSTGRESQL_PASSWORD=$(kubectl get secret --namespace default db-"$DEPLOYMENT_NAME"-postgresql -o jsonpath="{.data.postgresql-password}" | base64 -d)
- helm upgrade ci-"$DEPLOYMENT_NAME" cncf/exciproxy --install --force --wait --timeout 60m --set tls="$TLS" --set db.user=postgres --set db.password=$POSTGRESQL_PASSWORD --set db.name=ciproxy --set db.host=db-"$DEPLOYMENT_NAME"-postgresql --set db.pool=5 --set imagePullSecrets=productionsecret --set yaml=https://raw.githubusercontent.com/CrossCloudCI/cncf-configuration/"$CI_COMMIT_REF_NAME"/cross-cloud.yml --set project.segment_env="$PROJECT_SEGMENT_ENV" --set ingress.host="$CIPROXY_INGRESS" --set ingress.port=4001 --set image.repository="$CI_REGISTRY_IMAGE/ciproxy-$CI_COMMIT_REF_NAME" --set image.tag="$CI_COMMIT_SHA"