-
Notifications
You must be signed in to change notification settings - Fork 4
266 lines (266 loc) · 9.23 KB
/
ci.yaml
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: CI
on:
push:
branches:
- main
- "sync-map-*"
paths-ignore:
- "tools/**"
- "cloud/**"
pull_request:
paths-ignore:
- "tools/**"
- "cloud/**"
workflow_dispatch:
inputs:
deploy:
description: "Deploy?"
required: true
type: boolean
default: false
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: .maps-cache
key: maps-cache-cache-v2-build-${{ github.sha }}
restore-keys: |
maps-cache-cache-v2-build-
- name: Install dependencies
run: ./scripts/install.sh
- name: Build
run: source .envrc && make -j $(nproc)
- name: Test
run: source .envrc && make -j $(nproc) test
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gen-artifacts
path: gen
deploy-cdn:
runs-on: ubuntu-latest
needs: build-and-test
if: vars.MAPS_METADATA_BUCKET_NAME && (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Install Rclone
run: |
curl -L https://rclone.org/install.sh | sudo bash
- name: Deploy
run: ./scripts/deploy.sh ${{ github.sha }} ${{ !env.ACT && (github.ref == 'refs/heads/main' || github.event.inputs.deploy == true) }}
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_ACCESS_KEY_ID: ${{ vars.CLOUDFLARE_R2_ACCESS_KEY_ID }}
CLOUDFLARE_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
R2_BUCKET_NAME: ${{ vars.MAPS_METADATA_BUCKET_NAME }}
- name: Publish update on MQTT
uses: juhrlass/[email protected]
with:
protocol: mqtts
host: broker.hivemq.com
port: 8883
topic: dev.beyondallreason.maps-metadata/live_maps/updated:v1
message: ${{ github.sha }}
deploy-chobby:
runs-on: ubuntu-latest
needs: build-and-test
if: vars.ENABLE_BYAR_CHOBBY_PUSH && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: .maps-cache
key: maps-cache-cache-v2-chobby-${{ github.sha }}
restore-keys: |
maps-cache-cache-v2-chobby-
- name: Install dependencies
run: ./scripts/install.sh
- name: Checkout BYAR-Chobby
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/BYAR-Chobby
path: BYAR-Chobby
ssh-key: ${{ secrets.SSH_BYAR_CHOBBY_DEPLOY_KEY }}
- name: Patch Chobby
run: |
source .envrc
tsx scripts/js/src/update_byar_chobby_images.ts BYAR-Chobby
cp gen/mapDetails.lua BYAR-Chobby/LuaMenu/configs/gameConfig/byar/mapDetails.lua
cp gen/mapBoxes.conf BYAR-Chobby/LuaMenu/configs/gameConfig/byar/savedBoxes.dat
- name: Commit and push
run: |
cd BYAR-Chobby
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git remote -v
echo "[+] Git add"
git add .
echo "[+] Git status"
git status
if git diff-index --quiet HEAD; then
echo "No changes to commit"
exit 0
fi
echo "[+] Git commit"
git commit -m $'Automatic update of maps from maps-metadata\n\nFrom commit ${{ github.repository }}@${{ github.sha }}'
echo "[+] Git push"
git push
deploy-spads-config:
runs-on: ubuntu-latest
needs: build-and-test
if: vars.ENABLE_SPADS_CONFIG_PUSH && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Checkout SPADS Config
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/spads_config_bar
path: spads_config_bar
ssh-key: ${{ secrets.SSH_SPADS_CONFIG_DEPLOY_KEY }}
- name: Patch SPADS Config
run: |
cp gen/mapBoxes.conf spads_config_bar/etc/mapBoxes.conf
cp gen/mapLists.conf spads_config_bar/etc/mapLists.conf
cp gen/mapPresets.conf spads_config_bar/etc/mapPresets.conf
cp gen/mapBattlePresets.conf spads_config_bar/etc/mapBattlePresets.conf
python3 scripts/py/update_spads_conf.py spads_config_bar/etc/spads_cluster.conf
- name: Commit and push
run: |
cd spads_config_bar
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git remote -v
echo "[+] Git add"
git add .
echo "[+] Git status"
git status
if git diff-index --quiet HEAD; then
echo "No changes to commit"
exit 0
fi
echo "[+] Git commit"
git commit -m $'Automatic update of maps from maps-metadata\n\nFrom commit ${{ github.repository }}@${{ github.sha }}'
echo "[+] Git push"
git push
deploy-website:
runs-on: ubuntu-latest
needs: build-and-test
if: vars.WEBFLOW_COLLECTION_ID && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: .maps-cache
key: maps-cache-cache-v2-website-${{ github.sha }}
restore-keys: |
maps-cache-cache-v2-website-
- name: Install dependencies
run: ./scripts/install.sh
- name: Push to website
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
retry_wait_seconds: 10
command: |
source .envrc
tsx scripts/js/src/sync_to_webflow.ts sync
env:
WEBFLOW_API_TOKEN: ${{ secrets.WEBFLOW_API_TOKEN }}
WEBFLOW_COLLECTION_ID: ${{ vars.WEBFLOW_COLLECTION_ID }}
deploy-gdrive:
runs-on: ubuntu-latest
needs: build-and-test
if: vars.ENABLE_GDRIVE_PUSH && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch')
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- name: Install dependencies
run: ./scripts/install.sh
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/187238959541/locations/global/workloadIdentityPools/github-actions/providers/github
service_account: [email protected]
- name: Push to GDrive
run: |
source .envrc
tsx scripts/js/src/sync_to_gdrive.ts sync