-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.gitlab-ci.yml
172 lines (159 loc) · 3.41 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
168
169
170
171
172
image: node:12.16.3
cache:
key:
files:
- package-lock.json
prefix: ${CI_COMMIT_REF_SLUG}
paths:
- .npm/
variables:
CI: "true"
BUILD_NAME: "$CI_PROJECT_TITLE-$CI_COMMIT_REF_SLUG"
BUILD_DIR: "build"
RELEASE_DIR: "release"
stages:
- lint
- test
- build
- release
- release+source
- deploy
.npm_install: &npm_install
- npm ci --cache .npm --prefer-offline
lint:
tags:
- linux-docker
stage: lint
before_script:
- *npm_install
script:
- npm run lint
test:
tags:
- linux-docker
stage: test
before_script:
- *npm_install
script:
- npm run test
test_e2e:
tags:
- windows
stage: test
before_script:
- *npm_install
script:
- npm run test:e2e
- './ci/gitlab-commit-push.ps1 "test(e2e): update baseline snapshots [skip ci]"'
artifacts:
when: on_failure
paths:
- ./e2e/__image_snapshots__/__diff_output__
expire_in: 30 days
test_e2e_update:
tags:
- windows
stage: test
when: manual
before_script:
- *npm_install
script:
- npm run test:e2e-update
- './ci/gitlab-commit-push.ps1 "test(e2e): update baseline snapshots"'
build:
tags:
- linux-docker
stage: build
before_script:
- *npm_install
script:
- npm run build
artifacts:
name: "$BUILD_NAME-$(date +'%Y%m%d')"
paths:
- $BUILD_DIR
expire_in: 1 week
release:
tags:
- linux-docker
stage: release
only:
- main
dependencies:
- build
before_script:
- *npm_install
- apt-get update -qy
- apt-get install -y zip
script:
- rm -rf $BUILD_DIR/assets/ $BUILD_DIR/index.json
- mv $BUILD_DIR/index-release.json $BUILD_DIR/index.json
- mkdir $RELEASE_DIR
- zip -r "$RELEASE_DIR/$BUILD_NAME-$(date +'%Y%m%d').zip" $BUILD_DIR
- npx semantic-release
artifacts:
name: "$BUILD_NAME-$(date +'%Y%m%d')"
paths:
- $BUILD_DIR
expire_in: 1 week
release+source:
tags:
- linux-docker
stage: release+source
only:
- main
dependencies:
- release
script:
- echo "Creating release+source..."
artifacts:
name: "$BUILD_NAME-$(date +'%Y%m%d')"
paths:
- build
- public
- scripts
- src
- .eslintignore
- .gitattributes
- .gitignore
- .prettierignore
- "*.json"
- "*.js"
- "*.md"
exclude:
- public/assets/**/*
- release.config.js
expire_in: 1 week
deploy_dev:
tags:
- linux-docker
stage: deploy
only:
- main
dependencies:
- build
before_script:
- apt-get update -qy
- apt-get install -y lftp
script:
- lftp -e "open $FTP_HOSTNAME; user $FTP_USERNAME $FTP_PASSWORD; mirror -X .* -X .*/ --reverse --verbose --delete build/ $FTP_DEST_FOLDER_DEV/; bye"
environment:
name: dev
deploy_prod:
tags:
- linux-docker
stage: deploy
when: manual
only:
- main
dependencies:
- build
before_script:
- apt-get update -qy
- apt-get install -y lftp
script:
- rm -rf $BUILD_DIR/assets/ $BUILD_DIR/index.json
- mv $BUILD_DIR/index-release.json $BUILD_DIR/index.json
- lftp -e "open $FTP_HOSTNAME; user $FTP_USERNAME $FTP_PASSWORD; mirror -X .* -X .*/ --reverse --verbose --delete build/ $FTP_DEST_FOLDER_PROD/; bye"
environment:
name: prod