-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
60 lines (57 loc) · 2.62 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
before_script:
- echo " CI is running... "
# 编译项目
project-build:
stage: build
tags:
- build
only:
- /^preview\/.*$/
- /^release\/.*$/
script:
- docker run -i --rm -v $(pwd):/usr/work -w /usr/work golang:1.12 ./deploy.sh
- export VERSION=$(git --no-pager log -n 1 --no-merges --pretty=format:"%h" HEAD)
- docker-compose build
- docker-compose push
# ******************************************************************************************************
# ************************************** 测试环境配置 ****************************************************
# ******************************************************************************************************
notify-center-test-deploy:
stage: deploy
tags:
- build
only:
- /^preview\/.*$/
environment:
name: testing
script:
- export VERSION=$(git --no-pager log -n 1 --no-merges --pretty=format:"%h" HEAD)
- docker stack deploy --compose-file docker-compose.yml -c docker-compose-test.yml --with-registry-auth notify-center
- AUTHOR=$(git --no-pager log -n 1 --no-merges --pretty=format:"%an" HEAD)
- MESSAGE=$(git --no-pager log -n 1 --no-merges --pretty=format:"%s" HEAD)
- MSG="【推送网关V2】\n发布环境:🟡 测试环境 \n发布者:$AUTHOR \n版本hash:$VERSION \n更新日志:$MESSAGE"
- >
curl 'https://oapi.dingtalk.com/robot/send?access_token=*******'
-H 'Content-Type: application/json'
-d '{"msgtype":"text","text":{"content":"'"$MSG"'"}}'
# ******************************************************************************************************
# ************************************** 生产环境配置 ****************************************************
# ******************************************************************************************************
notify-center-prod:
stage: deploy
tags:
- release
only:
- release/2.0
environment:
name: production
script:
- export VERSION=$(git --no-pager log -n 1 --no-merges --pretty=format:"%h" HEAD)
- docker stack deploy --compose-file docker-compose.yml -c docker-compose-v2.0.yml --with-registry-auth notify-center
- AUTHOR=$(git --no-pager log -n 1 --no-merges --pretty=format:"%an" HEAD)
- MESSAGE=$(git --no-pager log -n 1 --no-merges --pretty=format:"%s" HEAD)
- MSG="【推送网关V2】\n发布环境:🟢 生产环境 \n发布者:$AUTHOR \n版本hash:$VERSION \n更新日志:$MESSAGE"
- >
curl 'https://oapi.dingtalk.com/robot/send?access_token=*******'
-H 'Content-Type: application/json'
-d '{"msgtype":"text","text":{"content":"'"$MSG"'"}}'