优化更新推送
This commit is contained in:
parent
940a8782c2
commit
80d1ab9bb2
13
defs/ci.py
13
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."
|
||||
|
Loading…
Reference in New Issue
Block a user