workflo 2

This commit is contained in:
Lilith Ashley Nyx Arson 🔥 2024-10-01 08:59:21 +02:00
parent c6941a9e3f
commit 59716ec8f5
2 changed files with 28 additions and 4 deletions

View file

@ -14,6 +14,22 @@ count["both"] = 0
cache = dict()
class fragile(object):
class Break(Exception):
"""Break out of the with statement"""
def __init__(self, value):
self.value = value
def __enter__(self):
return self.value.__enter__()
def __exit__(self, etype, value, traceback):
error = self.value.__exit__(etype, value, traceback)
if etype == self.Break:
return True
return error
if os.path.isfile("cache/licenses.json"):
with open("cache/licenses.json", "r") as f:
cache = json.load(f)
@ -47,10 +63,10 @@ for mod in glob.glob("pack/mods/*.toml"):
count[moddata["side"]] += 1
mods[moddata["name"]] = moddata
with open("wiki/Modlist.md", "w") as f:
with fragile(open("wiki/Modlist.md", "w")) as f:
if (count["server"] + count["client"] + count["both"]) == 0:
f.write("## No mods.")
break
raise fragile.Break
f.write("## Total Count\r\n")
f.write("<table>")
@ -104,10 +120,10 @@ with open("wiki/Modlist.md", "w") as f:
f.write("\r\n</tr>")
f.write("\r\n</table>")
with open("wiki/Licenses.md", "w") as f:
with fragile(open("wiki/Licenses.md", "w")) as f:
if (count["server"] + count["client"] + count["both"]) == 0:
f.write("## No mods.")
break
raise fragile.Break
for mod in mods:
data = mods[mod]

View file

@ -0,0 +1,8 @@
name: "Update wiki"
on: [push]
jobs:
restart:
if: "contains(github.event.head_commit.message, '[restart]')"
name: "Restart server"
runs-on: ubuntu-latest
steps: