-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
226 lines (207 loc) · 6.95 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Copyright 2025 Alina Marie Hartmann, Max Josef Overlack, Nils Paaßen,
# Nico Puelacher, Hanna Steffen, Lena Weuste
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
workflow:
rules:
- if: $CI_COMMIT_BRANCH
stages:
- license-lint-and-format
- build
- migrate
- deploy
- create-environment
default:
image: node:22-bookworm
before_script:
- npm i
cache:
paths:
- node_modules
license-lint-and-format-job:
stage: license-lint-and-format
variables:
VUE_LICENSE: |+
<!---
Copyright 2025 Alina Marie Hartmann, Max Josef Overlack, Nils Paaßen,
Nico Puelacher, Hanna Steffen, Lena Weuste
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
JS_LICENSE: |+
/*
* Copyright 2025 Alina Marie Hartmann, Max Josef Overlack, Nils Paaßen,
* Nico Puelacher, Hanna Steffen, Lena Weuste
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
YAML_LICENSE: |+
# Copyright 2025 Alina Marie Hartmann, Max Josef Overlack, Nils Paaßen,
# Nico Puelacher, Hanna Steffen, Lena Weuste
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
script:
- |
git ls-files '*.vue' | while read file; do
if ! grep 'Apache License' $file -q; then
echo "$VUE_LICENSE$(cat $file)" > $file
fi
done
- |
git ls-files '*.js' '*.mjs' '*.ts' '*.css' | while read file; do
if ! grep 'Apache License' $file -q; then
echo "$JS_LICENSE$(cat $file)" > $file
fi
done
- |
git ls-files '*.yaml' '*.yml' '*.toml' '*.gitignore' '*.dev.vars.example' '*.editorconfig' | while read file; do
if ! grep 'Apache License' $file -q; then
echo "$YAML_LICENSE$(cat $file)" > $file
fi
done
- npm run lint:fix || lint_failed=1
- npm run format
- |
if [[ $(git status --porcelain) ]]; then
git config user.name 'GitLab CI'
git config user.email [email protected]
git commit -am 'License, lint and format'
git push "https://gitlab-ci-token:$PROJECT_ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" HEAD:$CI_COMMIT_BRANCH
exit 1
fi
- |
if [[ $lint_failed = 1 ]]; then
echo -e "\e[31mLinting errors occurred that couldn't be fixed automatically"
exit 1
fi
build-job:
stage: build
script:
- npm run typecheck
- npm run build
artifacts:
paths:
- dist
migrate-stage:
rules:
- if: $CI_COMMIT_BRANCH == 'stage'
stage: migrate
script:
- npx wrangler d1 migrations apply DB --remote
migrate-production:
rules:
- if: $CI_COMMIT_BRANCH == 'main'
stage: migrate
script:
- npx wrangler d1 migrations apply DB --env=production --remote
deploy-app:
stage: deploy
script:
- npm run deploy-only -- --branch=$CI_COMMIT_BRANCH | tee deploy.log
artifacts:
paths:
- deploy.log
deploy-wiki:
rules:
- if: $CI_COMMIT_BRANCH == 'main'
changes:
- docs/**/*
stage: deploy
script:
- git clone "https://gitlab-ci-token:$PROJECT_ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.wiki.git"
- rm -rf docs/.git
- mv $CI_PROJECT_NAME.wiki/.git docs
- cd docs
- |
if [[ $(git status --porcelain) ]]; then
git config user.name 'GitLab CI'
git config user.email [email protected]
git add .
git commit -m 'Update wiki'
git push origin HEAD:main
fi
- rm -rf .git
create-environment-commit:
stage: create-environment
environment:
name: commit/$CI_COMMIT_SHA
url: $DYNAMIC_ENVIRONMENT_URL
deployment_tier: development
script:
- "deploy_url=$(grep -oP '(?<=✨ Deployment complete! Take a peek over at ).+' deploy.log)"
- echo DYNAMIC_ENVIRONMENT_URL=$deploy_url > deploy.env
- echo 'Creating "commit/$CI_COMMIT_SHA" environment'
artifacts:
reports:
dotenv: deploy.env
create-environment-branch:
rules:
- if: $CI_COMMIT_BRANCH != 'main' && $CI_COMMIT_BRANCH != 'stage'
stage: create-environment
environment:
name: branch/$CI_COMMIT_BRANCH
url: $DYNAMIC_ENVIRONMENT_URL
deployment_tier: development
script:
- "deploy_url=$(grep -oP '(?<=✨ Deployment alias URL: ).+' deploy.log)"
- echo DYNAMIC_ENVIRONMENT_URL=$deploy_url > deploy.env
- echo 'Creating "branch/$CI_COMMIT_BRANCH" environment'
artifacts:
reports:
dotenv: deploy.env
create-environment-stage:
rules:
- if: $CI_COMMIT_BRANCH == 'stage'
stage: create-environment
environment:
name: stage
url: https://foxbaseai-stage.maxoverlack.dev
deployment_tier: staging
script:
- echo 'Creating "stage" environment'
create-environment-production:
rules:
- if: $CI_COMMIT_BRANCH == 'main'
stage: create-environment
environment:
name: production
url: https://foxbaseai.maxoverlack.dev
script:
- echo 'Creating "production" environment'