Skip to content

Commit 24e9c2d

Browse files
authored
Merge pull request #73 from GeorgeK1ng/develop
Haven screenshots
2 parents fc827c9 + 6b01bf4 commit 24e9c2d

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

.github/validate_mod_json.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import sys
55
import urllib.request
6+
from io import StringIO
67

78
from ignore_json import ignore
89

@@ -11,8 +12,10 @@
1112
for filename in glob.glob(os.path.join('.', '*.json')):
1213
if filename not in ignore:
1314
print(f"Opening: {filename}")
14-
filecontent = open(filename, "r").read()
15-
15+
16+
with open(filename, "r") as file:
17+
filecontent = file.read()
18+
1619
try:
1720
modlist = jstyleson.loads(filecontent)
1821
except Exception as err:
@@ -23,6 +26,7 @@
2326
for mod, data in modlist.items():
2427
url = data["mod"].replace(" ", "%20")
2528
print(f"{mod}: {url}")
29+
2630
try:
2731
response = urllib.request.urlopen(url)
2832
print(f"✅ Download successful")
@@ -31,16 +35,16 @@
3135
print(f"❌ Download failed: {err}")
3236
continue
3337

34-
filecontent = response.read()
35-
3638
try:
37-
jstyleson.loads(filecontent)
39+
filecontent = response.read().decode("utf-8")
40+
jstyleson.load(StringIO(filecontent))
3841
print(f"✅ JSON valid")
3942
except Exception as err:
4043
error = True
4144
print(f"❌ JSON invalid:")
4245
print(str(err))
4346
continue
47+
4448
if error:
4549
sys.exit(os.EX_SOFTWARE)
4650
else:

.github/workflows/main.yml

+35-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ jobs:
1919
shell: bash
2020
steps:
2121
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
- name: Set up Python environment
25+
run: sudo apt update && sudo apt install -y python3 python3-pip
26+
- name: Install jstyleson
27+
run: pip3 install jstyleson
2228
- name: Validate json
23-
run: |
24-
python3 .github/validate_json.py
29+
run: python3 .github/validate_json.py
30+
2531
validate_mod_json:
2632
needs: validate_json
2733
runs-on: ubuntu-latest
@@ -30,9 +36,11 @@ jobs:
3036
shell: bash
3137
steps:
3238
- uses: actions/checkout@v3
39+
- name: Install jstyleson
40+
run: pip3 install jstyleson
3341
- name: Validate mod json
34-
run: |
35-
python3 .github/validate_mod_json.py
42+
run: python3 .github/validate_mod_json.py
43+
3644
update_size:
3745
needs: validate_json
3846
runs-on: ubuntu-latest
@@ -41,12 +49,33 @@ jobs:
4149
shell: bash
4250
steps:
4351
- uses: actions/checkout@v3
52+
with:
53+
fetch-depth: 0
54+
- name: Install jstyleson
55+
run: pip3 install jstyleson
56+
4457
- name: Update size
58+
run: python3 .github/update_size.py
59+
60+
- name: Determine branch and switch
61+
id: branch_info
4562
run: |
46-
python3 .github/update_size.py
47-
- name: Commit changes
63+
if [ -z "$GITHUB_HEAD_REF" ]; then
64+
branch_name=$(git symbolic-ref --short HEAD)
65+
else
66+
branch_name=$GITHUB_HEAD_REF
67+
fi
68+
echo "branch_name=$branch_name" >> $GITHUB_ENV
69+
git checkout $branch_name || git checkout -b $branch_name
70+
echo "Checked out branch: $branch_name"
71+
72+
- name: Set upstream for branch
73+
run: git push --set-upstream origin $branch_name
74+
75+
- name: Commit changes to the correct branch
4876
uses: EndBug/add-and-commit@v9
4977
with:
5078
default_author: github_actions
5179
message: Update sizes
5280
add: '*.json'
81+
push: --force

vcmi-1.6.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@
289289
"mod" : "https://raw.githubusercontent.com/vcmi-mods/haven-town/vcmi-1.6/haven-town/mod.json",
290290
"download" : "https://github.com/vcmi-mods/haven-town/archive/refs/heads/vcmi-1.6.zip",
291291
"screenshots" : [
292-
"https://raw.githubusercontent.com/vcmi-mods/haven-town/vcmi-1.5/screenshots/screen1.png",
293-
"https://raw.githubusercontent.com/vcmi-mods/haven-town/vcmi-1.5/screenshots/screen2.png"
292+
"https://raw.githubusercontent.com/vcmi-mods/haven-town/vcmi-1.6/screenshots/screen1.png",
293+
"https://raw.githubusercontent.com/vcmi-mods/haven-town/vcmi-1.6/screenshots/screen2.png",
294+
"https://raw.githubusercontent.com/vcmi-mods/haven-town/vcmi-1.6/screenshots/screen3.png"
294295
],
295296
"downloadSize" : 12.409
296297
},

0 commit comments

Comments
 (0)