-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
167 lines (154 loc) · 3.18 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
## https://docs.gitlab.com/ce/ci/yaml/README.html
###### GENERAL ################################################################
image: node:12.14.1
cache:
paths:
- node_modules/
- pages/node_modules/
###### TEMPLATES ##############################################################
.general: &general
tags:
- gitlab-org
variables:
GIT_STRATEGY: fetch
only:
- branches
except:
- /^v.*$/
.release-common: &release-common
<<: *general
stage: release
cache:
policy: pull
paths: []
dependencies:
- react app
artifacts:
expire_in: 1 week
paths:
- dist
only:
- release
retry:
max: 2
when: always
###### STAGES #################################################################
stages:
- install
- test
- build
- pre-release
- release
- deploy
###### JOBS ###################################################################
dependencies:
<<: *general
stage: install
cache:
policy: pull-push
paths:
- node_modules
script:
- yarn install
jest:
<<: *general
stage: test
cache:
policy: pull
paths:
- node_modules
dependencies:
- dependencies
artifacts:
paths:
- coverage
expire_in: 1 month
script:
- yarn test --verbose --forceExit --ci --coverage --colors
react app:
<<: *general
stage: build
environment:
name: ${CI_COMMIT_REF_NAME}
cache:
policy: pull
paths:
- node_modules
dependencies:
- dependencies
script:
- echo "NODE_ENV=production" > .env
- echo "CLIENT_SECRET=${CLIENT_SECRET}" >> .env
- echo "REACT_APP_PRODUCT_NAME=${npm_package_productName}" >> .env
- yarn react-build
artifacts:
expire_in: 1 week
paths:
- .env
- build
only:
- master
- release
tag version:
<<: *general
stage: pre-release
environment:
name: ${CI_COMMIT_REF_NAME}
cache:
policy: pull
paths: []
dependencies: []
script:
- mkdir -p ~/.ssh
- echo "${SSH_KEY}" > ~/.ssh/id_rsa
- chmod 700 ~/.ssh
- chmod 600 ~/.ssh/id_rsa
- echo "Host gitlab.com" > ~/.ssh/config
- echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
- git config --global user.name "Slothy CI/CD"
- git config --global user.email "3884597-slothy-cicd@users.noreply.gitlab.com"
- ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
- git remote remove origin
- git remote add gitlab https://slothy-cicd:${GITLAB_TOKEN}@gitlab.com/kirbo/slothy.git
- yarn create-tag
- git push gitlab --tags -o ci.skip
only:
- release
mac:
<<: *release-common
tags:
- macos
script:
- yarn
- yarn dist -m --publish always
linux:
<<: *release-common
image: kirbownz/electron-builder-node:latest
script:
- yarn
- yarn dist -l --publish always
windows:
<<: *release-common
image: kirbownz/electron-builder-wine:latest
script:
- yarn
- yarn dist -w --publish always
pages:
<<: *general
stage: deploy
cache:
policy: pull
paths: []
dependencies: []
script:
- cd pages
- yarn install
- yarn build
- rm -rf ../public
- mv build ../public
artifacts:
expire_in: 1 hour
paths:
- public
only:
- release