-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
93 lines (79 loc) · 4.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
stages:
- build
- deploy
maven-build-dev:
image: eclipse-temurin:22
stage: build
script:
- apt-get update && apt-get install -y maven
- mvn clean install jib:build -Djib.to.image=docker.io/"$DOCKER_HUB_USER"/$DOCKER_HUB_REPO:dev -Djib.to.auth.username="$DOCKER_HUB_USER" -Djib.to.auth.password="$DOCKER_HUB_TOKEN" -Djib.to.tags=dev
only:
refs:
- develop
maven-build-prod:
image: eclipse-temurin:22
stage: build
script:
- apt-get update && apt-get install -y maven
- mvn clean install jib:build -Djib.to.image=docker.io/"$DOCKER_HUB_USER"/$DOCKER_HUB_REPO:prod -Djib.to.auth.username="$DOCKER_HUB_USER" -Djib.to.auth.password="$DOCKER_HUB_TOKEN" -Djib.to.tags=prod
only:
refs:
- main
deploy-HH-WP-WEBADMIN-dev:
stage: deploy
image: dtzar/helm-kubectl:2.13.0
script:
- kubectl config set-cluster local --server="${HH_WP_WEBADMIN_ENDPOINT}"
- kubectl config set clusters.local.certificate-authority-data "${HH_WP_WEBADMIN_CERTIFICATE_AUTHORITY}"
- kubectl config set-credentials ${HH_WP_WEBADMIN_DEV_USER} --token="${HH_WP_WEBADMIN_DEV_USER_TOKEN}"
- kubectl config set-context "${HH_WP_WEBADMIN_DEV_NAMESPACE}" --cluster=local --user=${HH_WP_WEBADMIN_DEV_USER} --namespace="${HH_WP_WEBADMIN_DEV_NAMESPACE}"
- kubectl config use-context "${HH_WP_WEBADMIN_DEV_NAMESPACE}"
- kubectl version
- sed -i "s|DATA_REPO_GITLAB_TOKEN|${DATA_REPO_GITLAB_TOKEN}|g" k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml
- sed -i "s|DB_DEV_HOST|${DB_DEV_HOST}|g" k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml
- sed -i "s|DB_DEV_PORT|${DB_DEV_PORT}|g" k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml
- sed -i "s|DB_DEV_NAME|${DB_DEV_NAME}|g" k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml
- sed -i "s|DB_DEV_USER|${DB_DEV_USER}|g" k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml
- sed -i "s|DB_DEV_PASSWORD|${DB_DEV_PASSWORD}|g" k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml
- |
if kubectl apply -f k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml --record | grep -q unchanged; then
echo "=> Patching deployment to force image update."
kubectl patch -f k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml --record -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"ci-last-updated\":\"$(date +'%s')\"}}}}}"
else
echo "=> Deployment apply has changed the object, no need to force image update."
fi
- kubectl rollout status -f k8-deploy/dev/pdcm-admin-api-dev-deployment.yaml
- kubectl apply -f k8-deploy/dev/pdcm-admin-api-dev-service.yaml --record
- kubectl get pods,service,deploy,replicaset,ing -n "${HH_WP_WEBADMIN_DEV_NAMESPACE}"
only:
refs:
- develop
deploy-HH-WP-WEBADMIN-master:
stage: deploy
image: dtzar/helm-kubectl:2.13.0
script:
- kubectl config set-cluster local --server="${HH_WP_WEBADMIN_ENDPOINT}"
- kubectl config set clusters.local.certificate-authority-data "${HH_WP_WEBADMIN_CERTIFICATE_AUTHORITY}"
- kubectl config set-credentials ${HH_WP_WEBADMIN_USER} --token="${HH_WP_WEBADMIN_USER_TOKEN}"
- kubectl config set-context "${HH_WP_WEBADMIN_NAMESPACE}" --cluster=local --user=${HH_WP_WEBADMIN_USER} --namespace="${HH_WP_WEBADMIN_NAMESPACE}"
- kubectl config use-context "${HH_WP_WEBADMIN_NAMESPACE}"
- kubectl version
- sed -i "s|DATA_REPO_GITLAB_TOKEN|${DATA_REPO_GITLAB_TOKEN}|g" k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml
- sed -i "s|DB_PROD_HOST|${DB_PROD_HOST}|g" k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml
- sed -i "s|DB_PROD_PORT|${DB_PROD_PORT}|g" k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml
- sed -i "s|DB_PROD_NAME|${DB_PROD_NAME}|g" k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml
- sed -i "s|DB_PROD_USER|${DB_PROD_USER}|g" k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml
- sed -i "s|DB_PROD_PASSWORD|${DB_PROD_PASSWORD}|g" k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml
- |
if kubectl apply -f k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml --record | grep -q unchanged; then
echo "=> Patching deployment to force image update."
kubectl patch -f k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml --record -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"ci-last-updated\":\"$(date +'%s')\"}}}}}"
else
echo "=> Deployment apply has changed the object, no need to force image update."
fi
- kubectl rollout status -f k8-deploy/prod/pdcm-admin-api-prod-deployment.yaml
- kubectl apply -f k8-deploy/prod/pdcm-admin-api-prod-service.yaml --record
- kubectl get pods,service,deploy,replicaset,ing -n "${HH_WP_WEBADMIN_NAMESPACE}"
only:
refs:
- main