-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
84 lines (76 loc) · 2 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
image: siriusred/opstools
stages:
- prepare
- deploy
- notify
variables:
NOTIFICATION_URL: "https://hooks.slack.com/***************"
.deploy: &deploy_definition
stage: deploy
script:
- echo "$SSH_KEY" > asbl.key
- chmod 0600 asbl.key
- ansible-playbook --key-file asbl.key deploy_to_${stage}.yml
allow_failure: false
tagging_version:
stage: prepare
image: siriusred/opstools
script:
- git config --global user.email "deploy@deploy.com" && git config --global user.name "deploy"
- git remote set-url origin https://deploy:${deploy_pass}@gitlab.com/${CI_PROJECT_PATH}.git
- sed -i.bak 's/version:.*$/version:\ '$version'/' deploy_to_uat.yml
- sed -i.bak 's/version:.*$/version:\ '$version'/' deploy_to_stage.yml
- sed -i.bak 's/version:.*$/version:\ '$version'/' deploy_to_production.yml
- git commit -am "Branch was tagged ${version} for deploy this version"
- (git tag -l | grep $version && git tag -d ${version} && git push origin :refs/tags/${version}) || echo "Tag is non-exist"
- git tag -f ${version}
- git push origin --tags
only:
- triggers
except:
- tags
deploy:uat:
variables:
SSH_KEY: "$SSH_KEY_PRIV_DUSS"
stage: "uat"
tags:
- docker
- duss
only:
- develop
<<: *deploy_definition
deploy:stage:
variables:
SSH_KEY: "$SSH_KEY_PRIV_STAGE"
stage: "stage"
when: manual
allow_failure: true
tags:
- stage-docker
only:
- /^release\//
- /^hotfix\//
- /^v\d+\.\d+\.\d+$/
<<: *deploy_definition
deploy:production:
variables:
SSH_KEY: "$SSH_KEY_PRIV_AMS"
stage: "production"
when: manual
allow_failure: true
tags:
- ams-docker
only:
- /^release\//
- /^hotfix\//
- /^v\d+\.\d+\.\d+$/
<<: *deploy_definition
Notify:failed:
stage: notify
script:
- curl -X POST --data-urlencode "payload={\"text\":\"${CI_PROJECT_NAME} ${CI_COMMIT_TAG} failed\", \"icon_emoji\":\":red_circle:\"}" ${NOTIFICATION_URL}
tags:
- shell
when: on_failure
only:
- tags