diff --git a/defs/ci.py b/defs/ci.py index 25314bd..11d9530 100644 --- a/defs/ci.py +++ b/defs/ci.py @@ -58,11 +58,20 @@ async def get_artifact() -> Optional[Artifact]: return None +def format_branch(branch: str) -> str: + for i in ["-", ".", " ", ":"]: + branch = branch.replace(i, "_") + return branch + + def get_hash() -> str: req = get("https://api.github.com/repos/Grasscutters/Grasscutter/actions/runs?per_page=1&status=success") if req.status_code == 200: data = req.json() if data.get("workflow_runs", []): - return data["workflow_runs"][0]["head_commit"]["id"][:6] + " " + \ - data["workflow_runs"][0]["head_commit"]["message"][:50] + branch = data["workflow_runs"][0]["head_branch"] + hash_str = data["workflow_runs"][0]["head_commit"]["id"][:7] + message = data["workflow_runs"][0]["head_commit"]["message"][:200] + return f"#{format_branch(branch)} #{hash_str} \n\n" \ + f"{message}" return "Unknown."