-
Notifications
You must be signed in to change notification settings - Fork 13
249 lines (205 loc) · 6.31 KB
/
workflow.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Workflow
on:
workflow_dispatch:
repository_dispatch:
schedule:
- cron: "0 12 * * *" # Everyday at 12:00 UTC
jobs:
Job_U:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: |
npm install -g cytrus-v6
- name: Get Dofus version
run: |
cytrus-v6 download --game dofus --select "VERSION" --output data/U/
export DOFUS_VERSION=$(cat data/U/VERSION)
echo "::set-env name=DOFUS_VERSION::$DOFUS_VERSION"
echo The current Dofus version is $DOFUS_VERSION
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Get Datafus version
run: |
export DATAFUS_VERSION=$(curl https://api.github.com/repos/bot4dofus/Datafus/releases/latest | jq -r ".name")
echo "::set-env name=DATAFUS_VERSION::$DATAFUS_VERSION"
echo The latest Datafus version is $DATAFUS_VERSION
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Stop workflow if no new version
uses: actions/github-script@v6
with:
script: |
if(process.env.DOFUS_VERSION == process.env.DATAFUS_VERSION) {
core.info("Dofus and Datafus versions are the same. No new version. Stopping the workflow.");
const delay = ms => new Promise(res => setTimeout(res, ms));
github.rest.actions.cancelWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
});
while (true) {
core.info('Waiting for workflow to cancel ...');
await delay(5000);
}
}
- name: U1 - Update Dofus Client
run: |
cytrus-v6 download --game dofus --select "DofusInvoker.swf,**/*.d2i,**/*.d2o" --output data/U/
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_U
path: |
data/U/
Job_A:
runs-on: ubuntu-latest
needs: [Job_U]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: A1 - Extract DofusInvoker.swf
run: |
chmod +x src/A1.sh
src/A1.sh data/U/DofusInvoker.swf data/A/DofusInvoker/
- name: A2 - Build .json
run: |
python src/A2.py data/A/DofusInvoker/scripts/com/ data/A/events.json
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_A
path: |
data/A/
Job_B:
runs-on: ubuntu-latest
needs: [Job_U]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: B1 - Build .json
run: |
rm data/B/entities_json/*
python src/B1.py data/U/data/common/ data/B/entities_json/
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_B
path: |
data/B/
Job_C:
runs-on: ubuntu-latest
needs: [Job_U]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: C1 - Build .json
run: |
python src/C1.py data/U/data/i18n/ data/C/translations_json/
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_C
path: |
data/C/
Job_P:
runs-on: ubuntu-latest
needs: [Job_A, Job_B, Job_C]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Remove data folder
run: |
rm -r data/
- name: Download files Job U
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Download files Job A
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: Job_A
path: data/A/
- name: Download files Job B
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: Job_B
path: data/B/
- name: Download files Job C
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: Job_C
path: data/C/
- name: Get latest Dofus version
run: |
export DOFUS_VERSION=$(cat data/U/VERSION)
echo The current Dofus version is $DOFUS_VERSION
echo "::set-env name=VERSION::$DOFUS_VERSION"
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Create zip file
run: |
zip -r data.zip data/A/ data/B/ data/C/
- name: Split entities json
run: |
chmod +x devscript/split.sh
./devscript/split.sh data/B/entities_json/
- name: Commit and push
uses: EndBug/add-and-commit@v9
with:
add: '["data/A/", "data/B/", "data/C/"]'
message: 'Update ${{ env.VERSION }}'
push: true
- name: Publish release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ env.VERSION }}
prerelease: false
title: ${{ env.VERSION }}
files: |
./data.zip