This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
101 lines (94 loc) · 3.27 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
94
95
96
97
98
99
100
101
# Make.org Control Center
# Copyright (C) 2018 Make.org
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
image: makeorg/docker-sbt-coursier-nvm
variables:
CI_BUILD: "true"
SBT_OPTS: "-Xms2G -Xmx2G -Dfile.encoding=UTF-8"
IMAGE: "/make-bo"
stages:
- build
- deploy
- merge
build:
stage: build
tags:
- docker
before_script:
- rm -rf /root/.sbt/1.0/plugins
- export IMAGE_VERSION=`git rev-parse --short=10 HEAD`
- mkdir -p /var/lib/docker
- mount -t tmpfs -o size=12G tmpfs /var/lib/docker
- if [ ! -e /var/run/docker.sock ]; then DOCKER_DRIVER=overlay2 dockerd & fi
- until docker ps; do echo "waiting for docker to be up..."; sleep 0.5; done
- docker login "https://$NEXUS_URL" --username "$NEXUS_USER" --password "$NEXUS_PASSWORD"
- . /root/.profile
- echo $(docker pull $NEXUS_URL$IMAGE:$IMAGE_VERSION)
script:
- >
if [[ -z $(docker images -q $NEXUS_URL$IMAGE:$IMAGE_VERSION) ]];then
sbt clean publishLocal
docker push $NEXUS_URL$IMAGE:$IMAGE_VERSION
fi
- docker tag $NEXUS_URL$IMAGE:$IMAGE_VERSION $NEXUS_URL$IMAGE:$CI_COMMIT_REF_NAME-latest
- docker push $NEXUS_URL$IMAGE:$CI_COMMIT_REF_NAME-latest
merge-to-prod:
stage: merge
when: manual
only:
- preproduction
allow_failure: false
script:
- mkdir -p ~/.ssh/
- chmod 700 ~/.ssh
- ssh-keyscan -t rsa gitlab.com > ~/.ssh/known_hosts
- echo "${DEPLOY_PRIVATE_KEY}" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- export CI_PUSH_REPO=`echo $CI_REPOSITORY_URL | perl -pe 's#.*@(.+?(\:\d+)?)/#git@\1:#'`
- echo "Target repo is ${CI_PUSH_REPO}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- git remote set-url origin "${CI_PUSH_REPO}"
- git checkout production
- git merge --ff-only origin/preproduction
- git push origin production:production
deploy-preproduction:
stage: deploy
environment:
name: preproduction
only:
- preproduction
script:
- >
curl -D - -X "POST"
-H "Accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-H "X-Rundeck-Auth-Token: $RUNDECK_PREPROD_TOKEN"
--data-urlencode "argString=-version $CI_COMMIT_REF_NAME-latest"
$RUNDECK_PREPROD_URL/api/16/job/$RUNDECK_PREPROD_JOB_ID/run
deploy-production:
stage: deploy
environment:
name: production
only:
- production
script:
- >
curl -D - -X "POST"
-H "Accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-H "X-Rundeck-Auth-Token: $RUNDECK_PROD_TOKEN"
--data-urlencode "argString=-version $CI_COMMIT_REF_NAME-latest"
$RUNDECK_PROD_URL/api/16/job/$RUNDECK_PROD_JOB_ID/run