-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
174 lines (160 loc) · 4.21 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
stages:
- test
- build
- deploy
- housekeeping
image: node:16
variables:
GIT_DEPTH: 5
FF_USE_FASTZIP: 'true'
TRANSFER_METER_FREQUENCY: 5s # will display transfer progress every 5 seconds for artifacts and remote caches.
.node_mod_installation:
before_script:
- npm config set @degrens-21:registry https://gitlab.pieter557.dscloud.me/api/v4/packages/npm/
- npm config set -- '//gitlab.pieter557.dscloud.me/api/v4/packages/npm/:_authToken' "${CI_JOB_TOKEN}"
- npm config set always-auth true
- corepack enable
- corepack prepare pnpm@latest --activate
- pnpm config set store-dir .pnpm-store
- pnpm install
.cache_modules:
cache:
key: '$CI_COMMIT_REF_NAME-pnpm-store'
paths:
- .pnpm-store
.js_changes:
only:
refs:
- UPD
- merge_requests
changes:
- '**/*.js'
- '**/*.ts'
- '**/*.jsx'
- '**/*.tsx'
- '**/*.css'
- '**/*.scss'
- '**/*.html'
- '**/package.json'
- '**/pnpm-lock.yaml'
validate json:
stage: test
image: node:16
script:
- cd ./tools/json-validator
- yarn --pure-lockfile
- yarn start
only:
refs:
- main
- UPD
- merge_requests
changes:
- '**/*.json'
validate Errorlogger:
image: python:3-slim
stage: test
script:
- python ./tools/manifest-check.py
- exit "${?}"
only:
refs:
- main
- UPD
- merge_requests
changes:
- '**/fxmanifest.lua'
validate db migrations:
stage: test
image: node:16
services:
- name: mariadb:10.7
alias: mariadb
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: degrens2
MYSQL_USER: dguser
MYSQL_PASSWORD: dgpw
script:
- echo 'DATABASE_URL=mysql://dguser:dgpw@mariadb/degrens2?charset=utf8mb4' > ./packages/db/.env
- cd packages/db
- yarn global add prisma
- yarn db:deploy
only:
refs:
- main
- UPD
- merge_requests
changes:
- 'packages/db/*'
JS linting:
extends:
- .node_mod_installation
- .cache_modules
- .js_changes
stage: test
script:
- pnpm format -- --loglevel error
- pnpm lint
TS dev build:
tags:
- amd64
extends:
- .node_mod_installation
- .cache_modules
- .js_changes
stage: build
script:
- pnpm build:dev --force
TS prod build:
tags:
- amd64
extends:
- .node_mod_installation
- .cache_modules
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == "main" && $SHOULD_DEPLOY == "true"
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
stage: build
script:
- pnpm build
Unschedule deploy:
stage: housekeeping
image: alpine:latest
before_script:
- apk add --no-cache curl jq
script:
# Force ownership
- 'curl --request POST --header "PRIVATE-TOKEN: $API_TOKEN" https://gitlab.pieter557.dscloud.me/api/v4/projects/26/pipeline_schedules/1/take_ownership | jq'
# unschedule deploy
- 'curl --request PUT --header "PRIVATE-TOKEN: $API_TOKEN" --form "value=false" https://gitlab.pieter557.dscloud.me/api/v4/projects/26/pipeline_schedules/1/variables/SHOULD_DEPLOY | jq'
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == "main" && $SHOULD_DEPLOY == "true"
Schedule deploy:
stage: deploy
image: alpine:latest
before_script:
- apk add --no-cache curl jq
script:
# Force ownership
- 'curl --request POST --header "PRIVATE-TOKEN: $API_TOKEN" https://gitlab.pieter557.dscloud.me/api/v4/projects/26/pipeline_schedules/1/take_ownership | jq'
# schedule deploy
- 'curl --request PUT --header "PRIVATE-TOKEN: $API_TOKEN" --form "value=true" https://gitlab.pieter557.dscloud.me/api/v4/projects/26/pipeline_schedules/1/variables/SHOULD_DEPLOY | jq'
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "main"
Deploy production:
stage: deploy
image: ubuntu:jammy
variables:
SERVER_IP: '10.0.0.1'
SERVER_USER: 'fivem'
tags:
- windows
- production
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == "main" && $SHOULD_DEPLOY == "true"
script:
- C:\Users\fivem\Desktop\degrens-main\pull.bat
- C:\Users\fivem\Desktop\degrens-main\build.bat