-
-
Notifications
You must be signed in to change notification settings - Fork 327
361 lines (348 loc) · 13.1 KB
/
BuildPages.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: Build Pages
on:
pull_request_target:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- 'newicons/appfilter.xml'
push:
branches: ['Arcticons-Pages','main']
paths:
- 'docs/**'
- 'newicons/appfilter.xml'
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '30 5 * * 0,3'
workflow_dispatch:
inputs:
run_colormapping:
description: "Run Create_Colormappping job"
type: boolean
required: false
default: false
run_requestjson:
description: "Run Create_requestjson job"
type: boolean
required: false
default: false
run_Request_Update:
description: "Run Update_Requests job"
type: boolean
required: false
default: false
run_fetch_and_push_file:
description: "Run fetch_and_push_file job"
type: boolean
required: false
default: false
jobs:
fetch_and_push_file:
name: Fetch and Push File
if: ${{ github.repository == vars.REPOSITORY && ((github.event_name == 'push' && github.ref_name == vars.MAIN_BRANCH) || (github.event_name == 'workflow_dispatch' && inputs.run_fetch_and_push_file == true)) }}
runs-on: ubuntu-latest
concurrency:
group: push
cancel-in-progress: false
environment:
name: FileSync
env:
SOURCE_BRANCH: ${{vars.MAIN_BRANCH}}
TARGET_BRANCH: ${{vars.PAGES_BRANCH}}
FILE_PATH: newicons/appfilter.xml
steps:
# Step 1: Checkout the repository
- name: Checkout main Repository
uses: actions/checkout@v4
with:
ref: ${{vars.MAIN_BRANCH}}
path: main
# Step 2: Checkout the 2. repository
- name: Checkout Arcticons-Pages Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
path: pages
# Step 3: Fetch the file from the source branch
- name: Copy File from main to Arcticons-Pages
run: |
rm pages/newicons/appfilter.xml
cp main/newicons/appfilter.xml pages/newicons/appfilter.xml
# Step 4: Commit and push changes
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd pages
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add $FILE_PATH
git commit -m "Update $FILE_PATH from $SOURCE_BRANCH to $TARGET_BRANCH"
git push
check_appfilter:
name: Check appfilter.xml from pull_request
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
permissions:
pull-requests: write # Required to comment on PRs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.user.login }}/${{ github.event.pull_request.head.ref }}
cancel-in-progress: true
steps:
- name: Checkout Repository ${{ github.event.pull_request.user.login }}/${{ github.event.pull_request.head.ref }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
sparse-checkout: |
newicons/appfilter.xml
sparse-checkout-cone-mode: false
- name: Install xmllint
shell: bash
run: |
sudo apt update
sudo apt install -y libxml2-utils
- name: Validate appfilter.xml
id: validate
run: |
if ! PARSE_OUTPUT=$(xmllint --noout newicons/appfilter.xml 2>&1) ; then
echo "Parsing appfilter.xml failed."
echo -e "Parsing of 'newicons/appfilter.xml' failed. Please fix the XML syntax errors. \n \`\`\` \n $PARSE_OUTPUT \n \`\`\`" >> comment_markdown.md
exit 1
else
echo "Parsing succeeded."
fi
- name: Post failure comment to PR
if: failure()
run: |
gh pr comment ${{ github.event.pull_request.number }} --body-file comment_markdown.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Update_Requests:
if: ${{ github.repository == vars.REPOSITORY && ( inputs.run_Request_Update == true || github.event_name == 'schedule') && vars.AUTOMATIC_UPDATE == 'true' }}
environment:
name: Request-Update
concurrency:
group: 'push'
cancel-in-progress: false
runs-on: ubuntu-latest
outputs:
changes_detected: ${{ steps.check_changes.outputs.changes_detected }}
request_changes: ${{ steps.check_changes.outputs.Request_changes }}
image_changes: ${{ steps.check_changes.outputs.Image_changes }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- run: pip install -r .github/workflows/requirements.txt
- name: Execute Python Script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REQUEST_LIMIT: ${{ vars.REQUEST_LIMIT }}
MONTHS_LIMIT: ${{ vars.MONTHS_LIMIT }}
MIN_REQUESTS: ${{ vars.MIN_REQUESTS }}
SUBJECT_PREFIX: ${{ vars.SUBJECT_PREFIX }}
SUBJECT_SUFFIX: ${{ vars.SUBJECT_SUFFIX }}
IMAP_SERVER: ${{ secrets.IMAP_SERVER }}
IMAP_USERNAME: ${{ secrets.IMAP_USERNAME }}
IMAP_PASSWORD: ${{ secrets.IMAP_PASSWORD }}
run: |
mkdir mail
python .github/workflows/email_parser_auto.py mail newicons/appfilter.xml docs/extracted_png docs/assets/
rm -r mail
- name: Check for changes
id: check_changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
# Get the list of changed files
CHANGED_FILES=$(git diff --cached --name-only)
# Check if there are any changes
if [ -z "$CHANGED_FILES" ]; then
echo "No changes detected"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "changes_detected=true" >> $GITHUB_OUTPUT
# Set different outputs depending on which path changed
if echo "$CHANGED_FILES" | grep -q "^docs/assets/requests.txt"; then
echo "Request_changes=true" >> $GITHUB_OUTPUT
fi
if echo "$CHANGED_FILES" | grep -q "^docs/extracted_png/"; then
echo "Image_changes=true" >> $GITHUB_OUTPUT
fi
# You can add more checks for other directories or files here as needed
fi
- name: Commit and Push if Changes Exist
if: ${{ steps.check_changes.outputs.changes_detected == 'true' }}
run: |
git commit -m "Automated Request Update"
git push
Check_FilePath:
name: Check File Path changes
if: ${{github.event_name == 'push' && github.ref_name == vars.PAGES_BRANCH}}
runs-on: ubuntu-latest
outputs:
imagechange: ${{ steps.changes.outputs.images }}
requestchange: ${{ steps.changes.outputs.requests }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
images:
- 'docs/extracted_png/**'
requests:
- 'docs/assets/requests.txt'
base: ${{vars.PAGES_BRANCH}}
Create_Colormappping:
name: Create Colormapping
needs: [Check_FilePath, Update_Requests]
if: ${{ ((needs.Check_FilePath.outputs.imagechange == 'true' && github.event_name == 'push') || (((github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && needs.Update_Requests.outputs.image_changes == 'true') || (inputs.run_colormapping == true && inputs.run_Request_Update == false ))) && !failure() }}
runs-on: ubuntu-latest
concurrency:
group: 'colormapping'
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- run: pip install -r .github/workflows/requirements.txt
- name: Execute Python Script
id: colormapping_done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python .github/workflows/create_colormapping.py
- name: Upload Colormapping
uses: actions/upload-artifact@v4
with:
name: colormapping
path: docs/assets/image_color_counts.xml
Create_requestjson:
name: Create Requestjson
needs: [Check_FilePath, Update_Requests]
if: ${{ ((needs.Check_FilePath.outputs.requestchange == 'true' && github.event_name == 'push') || (((github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && needs.Update_Requests.outputs.request_changes == 'true') || (inputs.run_requestjson == true && inputs.run_Request_Update == false ))) && !failure() }}
runs-on: ubuntu-latest
concurrency:
group: 'requestjson'
cancel-in-progress: true
outputs:
requestjson_done: ${{ steps.requestjson_done.outcome }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- run: pip install -r .github/workflows/requirements.txt
- name: Execute Python Script
id: requestjson_done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python .github/workflows/getGPlayData.py
- name: Upload Requestjson
uses: actions/upload-artifact@v4
with:
name: requestjson
path: docs/assets/requests.json
Push_Files:
needs: [Create_Colormappping, Create_requestjson]
runs-on: ubuntu-latest
concurrency:
group: 'push'
cancel-in-progress: false
if: ${{(needs.Create_Colormappping.result == 'success' || needs.Create_requestjson.result == 'success') && !failure()}}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
- name: Download Colormapping and Requestjson
uses: actions/download-artifact@v4
with:
path: docs/assets
merge-multiple: true
- name: Check for changes
id: check_changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
# Get the list of changed files
CHANGED_FILES=$(git diff --cached --name-only)
# Check if there are any changes
if [ -z "$CHANGED_FILES" ]; then
echo "No changes detected"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "changes_detected=true" >> $GITHUB_OUTPUT
fi
- name: Commit and Push if Changes Exist
if: ${{ steps.check_changes.outputs.changes_detected == 'true' }}
run: |
git commit -m "Automated updates from Colormappping and Requestjson jobs"
git push
parse_and_combine:
name: Parse and Combine Appfilter
needs: [check_appfilter, Push_Files,fetch_and_push_file,Update_Requests]
if: ${{(needs.check_appfilter.result == 'success' || needs.Push_Files.result == 'success' || needs.fetch_and_push_file.result == 'success' ||(needs.Update_Requests.result == 'success' && needs.Update_Requests.outputs.changes_detected == 'true' )) && !failure()}}
permissions:
pages: write # Required to deploy to GitHub Pages
id-token: write # Required to deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
concurrency:
group: 'pages'
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- run: pip install -r .github/workflows/requirements.txt
- name: Execute Python Script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python .github/workflows/combine_appfilter.py
- name: Move combinded Appfilter
run: mv combined_appfilter.xml docs/assets/combined_appfilter.xml
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload docs folder
path: 'docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4