markdown improvement

This commit is contained in:
Prox 2026-03-06 18:16:13 +02:00
parent aa4aa32655
commit 0eef866266

View File

@ -73,23 +73,34 @@ jobs:
print(f"[{env}] Reconciler call failed: {e}") print(f"[{env}] Reconciler call failed: {e}")
continue continue
# Format as markdown # Format as markdown grouped by action
ops = data.get("operations", []) ops = data.get("operations", [])
summary = data.get("summary", {}) summary = data.get("summary", {})
lines = [f"## Reconciliation Plan: `{env}`\n"] lines = [f"## Reconciliation Plan: `{env}`\n"]
if not ops: if not ops:
lines.append("No changes detected.\n") lines.append("No changes detected.\n")
else: else:
lines.append("| Operation | Name |") groups = {"Create": [], "Update": [], "Delete": []}
lines.append("|-----------|------|")
for op in ops: for op in ops:
lines.append(f"| `{op['type']}` | {op['name']} |") t = op["type"]
lines.append("") if t.startswith("create"): groups["Create"].append(op)
lines.append( elif t.startswith("delete"): groups["Delete"].append(op)
f"**Summary:** {summary.get('created',0)} create, " else: groups["Update"].append(op)
f"{summary.get('updated',0)} update, "
f"{summary.get('deleted',0)} delete" for action, items in groups.items():
) if not items:
continue
emoji = {"Create": "+", "Update": "~", "Delete": "-"}[action]
lines.append(f"### {action} ({len(items)})\n")
lines.append("| Resource | Name |")
lines.append("|----------|------|")
for op in items:
resource = op["type"].split("_", 1)[1] if "_" in op["type"] else op["type"]
lines.append(f"| {resource} | {op['name']} |")
lines.append("")
c, u, d = summary.get("created", 0), summary.get("updated", 0), summary.get("deleted", 0)
lines.append(f"**Total: {c} create, {u} update, {d} delete**")
comment = "\n".join(lines) comment = "\n".join(lines)
print(comment) print(comment)