-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
77 lines (67 loc) · 2.29 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
# include:
# - project: 'louzhijian/devops'
# ref: master
# file: 'devops/sonar-scanner.yml'
stages:
# - sonarqube
- docker-dev
- deploy-dev
- deploy-test
- docker-prd
- deploy-prd
variables:
DOCKER_Offical_WebSite_PATH: src/MASA.OfficialWebsite.WebApp/Dockerfile
NEW_IMAGE_Offical_WebSite_Dev: $CI_ALI_REGISTRY_DOMAIN/masa/masa-official-website:dev-$CI_PIPELINE_ID
# NEW_IMAGE_Offical_WebSite: $CI_ALI_REGISTRY_DOMAIN/masa/masa-official-website:$CI_COMMIT_TAG
NEW_IMAGE_Offical_WebSite: $CI_ALI_REGISTRY_DOMAIN/masa/masa-official-website:$CI_PIPELINE_ID
docker-build-dev:
stage: docker-dev
tags:
- linux-shell
before_script:
- docker login --username=$CI_ALI_REGISTRY_USER --password=$CI_ALI_REGISTRY_PASSWD $CI_ALI_REGISTRY_DOMAIN
only:
- main
script:
- docker build -f $DOCKER_Offical_WebSite_PATH -t $NEW_IMAGE_Offical_WebSite_Dev .
- docker push $NEW_IMAGE_Offical_WebSite_Dev
after_script:
- docker rmi $NEW_IMAGE_Offical_WebSite_Dev
deploy-dev:
stage: deploy-dev
tags:
- linux-shell
# before_script:
# - docker login --username=$CI_ALI_REGISTRY_USER --password=$CI_ALI_REGISTRY_PASSWD $CI_ALI_REGISTRY_DOMAIN
only:
- main
script:
- echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
- kubectl --kubeconfig ./config set image deployment/masa-official-website masa-official-website=$NEW_IMAGE_Offical_WebSite_Dev -n masa-official-website-dev
retry: 2
docker-build-prd:
stage: docker-prd
tags:
- linux-shell
before_script:
- docker login --username=$CI_ALI_REGISTRY_USER --password=$CI_ALI_REGISTRY_PASSWD $CI_ALI_REGISTRY_DOMAIN
only:
- main
script:
- docker build -f $DOCKER_Offical_WebSite_PATH -t $NEW_IMAGE_Offical_WebSite .
- docker push $NEW_IMAGE_Offical_WebSite
after_script:
- docker rmi $NEW_IMAGE_Offical_WebSite
deploy-prd:
stage: deploy-prd
tags:
- linux-shell
# before_script:
# - docker login --username=$CI_ALI_REGISTRY_USER --password=$CI_ALI_REGISTRY_PASSWD $CI_ALI_REGISTRY_DOMAIN
only:
- main
script:
- echo $KUBE_CONFIG_LSD_PRD_YDY | base64 -d > ./config
- kubectl --kubeconfig ./config set image deployment/masa-official-website masa-official-website=$NEW_IMAGE_Offical_WebSite -n masa-official-website
retry: 2
when: manual