forked from digitalautonomy/wahay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
129 lines (120 loc) · 4.33 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
image: rbonifaz/wahay-build:latest
variables:
PACKAGE_PATH: /go/src/github.com/digitalautonomy/wahay
DOCKER_DRIVER: overlay2
stages:
- build
- check
- deploy
# A hack to make Golang-in-Gitlab happy
.anchors:
- &inject-gopath
mkdir -p $(dirname ${PACKAGE_PATH})
&& ln -s ${CI_PROJECT_DIR} ${PACKAGE_PATH}
&& cd ${PACKAGE_PATH}
build:
stage: build
before_script:
- *inject-gopath
script:
- make deps-ci
- make build-ci
artifacts:
paths:
- bin/wahay-*
test:
stage: check
before_script:
- *inject-gopath
script:
- make deps-ci
- make test
coverage:
stage: check
before_script:
- *inject-gopath
coverage: '/total:.*?(\d+\.\d+\%)/'
script:
- make deps-ci
- make cover-ci
artifacts:
paths:
- coverage.html
quality:
stage: check
before_script:
- *inject-gopath
script:
- make deps-ci
- make quality
deploy_staging:
image: rbonifaz/wahay-deploy:latest
stage: deploy
before_script:
- export SSH_PORT=2326
- 'export DO_SSH="ssh -p${SSH_PORT} [email protected]"'
- 'eval $(ssh-agent -s)'
- 'ssh-add <(echo "$DEPLOY_STAGING_SSH_PRIVATE_KEY")'
- mkdir -p ~/.ssh; chmod 700 ~/.ssh
- 'echo -e "[staging.wahay.app]:${SSH_PORT},[185.108.76.88]:${SSH_PORT} ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEiKOqqE2wJo4OnAvgbCPLsnObcSJuoYQU0cW3QRMPqK4XHeo9RTxOE4jt+40Gy3wfzzo7q1fmUJ/QZrORcNI6Y=" >> ~/.ssh/known_hosts'
- chmod 644 ~/.ssh/known_hosts
- 'echo "$GPG_SIGNING_SUBKEY" | gpg --import'
environment:
name: staging
url: https://staging.wahay.app
only:
- master
script:
- 'export DEPLOY_DIR=/home/wahay/tmp/deploy_binaries'
- '$DO_SSH mkdir -p $DEPLOY_DIR'
- '$DO_SSH rm -rf $DEPLOY_DIR/*'
- 'export BINARY_NAME=$(find bin -name "wahay*" | head -1)'
- 'sha256sum $BINARY_NAME > $BINARY_NAME.sha256sum'
- 'gpg --detach-sign --armor -u 01242FFAB8CE1EC0C8F54456A8854162D28F171E $BINARY_NAME.sha256sum'
- 'scp -P${SSH_PORT} $BINARY_NAME* [email protected]:$DEPLOY_DIR/'
- 'scp -P${SSH_PORT} deployment/*sh [email protected]:bin/'
- 'scp -P${SSH_PORT} deployment/*rb [email protected]:bin/'
- 'scp -P${SSH_PORT} deployment/*html [email protected]:bin/'
- '$DO_SSH chmod +x bin/*sh'
- deployment/create-bundles.sh
- 'scp -P${SSH_PORT} publish-bundles/* [email protected]:$DEPLOY_DIR/'
- deployment/create-linux-packages.sh
- 'scp -P${SSH_PORT} publish-linux-packages/* [email protected]:$DEPLOY_DIR/'
- '$DO_SSH bin/publish-downloads.sh'
- 'scp -P${SSH_PORT} deployment/supported-*-distros.txt [email protected]:$DEPLOY_DIR'
deploy_production:
image: rbonifaz/wahay-deploy:latest
stage: deploy
before_script:
- export SSH_PORT=2387
- 'export DO_SSH="ssh -p${SSH_PORT} [email protected]"'
- "eval $(ssh-agent -s)"
- 'ssh-add <(echo "$DEPLOY_PRODUCTION_SSH_PRIVATE_KEY")'
- mkdir -p ~/.ssh; chmod 700 ~/.ssh
- 'echo -e "[wahay.app]:${SSH_PORT},[185.108.76.87]:${SSH_PORT} ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBD7qdL4lFlIQwRU2h2fV6oIMBZl1ifd6bbcajd8iRYaFQfVvj7qxGvorfaBETyquGe+lk0xw3NrcJCfK1LvT2Wo=" >> ~/.ssh/known_hosts'
- chmod 644 ~/.ssh/known_hosts
- 'echo "$GPG_SIGNING_SUBKEY" | gpg --import'
environment:
name: production
url: https://wahay.app
when: manual
only:
- master
script:
- 'export DEPLOY_DIR=/home/wahay/tmp/deploy_binaries'
- '$DO_SSH mkdir -p $DEPLOY_DIR'
- '$DO_SSH rm -rf $DEPLOY_DIR/*'
- 'export BINARY_NAME=$(find bin -name "wahay*" | head -1)'
- 'sha256sum $BINARY_NAME > $BINARY_NAME.sha256sum'
- 'gpg --detach-sign --armor -u 01242FFAB8CE1EC0C8F54456A8854162D28F171E $BINARY_NAME.sha256sum'
- 'scp -P${SSH_PORT} $BINARY_NAME* [email protected]:$DEPLOY_DIR/'
- 'scp -P${SSH_PORT} deployment/*sh [email protected]:bin/'
- 'scp -P${SSH_PORT} deployment/*rb [email protected]:bin/'
- 'scp -P${SSH_PORT} deployment/*html [email protected]:bin/'
- '$DO_SSH chmod +x bin/*sh'
- deployment/create-bundles.sh
- 'scp -P${SSH_PORT} publish-bundles/* [email protected]:$DEPLOY_DIR/'
- deployment/create-linux-packages.sh
- 'scp -P${SSH_PORT} publish-linux-packages/* [email protected]:$DEPLOY_DIR/'
- '$DO_SSH bin/publish-downloads.sh'
- 'scp -P${SSH_PORT} deployment/supported-*-distros.txt [email protected]:$DEPLOY_DIR'