Skip to content

Commit 5db473f

Browse files
committed
refactor: simplify comment formatting in post_pr_comment by using markdown representation and adding attribution footer
1 parent e4fe16f commit 5db473f

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

src/gha_failure_analysis/output/github.py

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,20 @@ def post_pr_comment(
3737
repo = g.get_repo(repository)
3838
pr = repo.get_pull(pr_number)
3939

40-
run_link = report._get_run_url()
41-
comment_body = f"""## 🤖 Workflow Failure Analysis
40+
# Use the same detailed format as the job summary
41+
comment_body = report.to_markdown()
4242

43-
**Workflow:** {report.workflow_name} {run_link}
44-
**Category:** {report.category.title()}
45-
46-
{report.summary}
47-
48-
### 📋 Technical Details
43+
# Add footer with attribution
44+
repo_url = "https://github.com/calebevans/gha-failure-analysis"
45+
comment_body += f"""
4946
50-
{report.detailed_analysis}
51-
"""
47+
---
5248
53-
if report.step_analyses:
54-
comment_body += """
55-
<details>
56-
<summary><b>🔍 Evidence</b></summary>
49+
<sub>
5750
58-
"""
59-
for analysis in report.step_analyses:
60-
comment_body += f"### {analysis.job_name} / {analysis.step_name}\n\n"
61-
comment_body += f"**Category:** `{analysis.failure_category}` \n"
62-
comment_body += f"**Root Cause:** {analysis.root_cause}\n\n"
63-
if analysis.evidence:
64-
comment_body += "**Logs:**\n\n"
65-
for item in analysis.evidence:
66-
source = item.get("source", "unknown")
67-
content = item.get("content", "").replace("`", "'")
68-
comment_body += (
69-
f"<details>\n<summary><code>{source}</code></summary>\n\n"
70-
f"```\n{content}\n```\n</details>\n\n"
71-
)
72-
comment_body += "\n"
73-
74-
comment_body += "</details>\n"
51+
Generated by [gha-failure-analysis]({repo_url})
7552
76-
repo_url = "https://github.com/calebevans/gha-failure-analysis"
77-
comment_body += f"""
78-
---
79-
*Analysis powered by [gha-failure-analysis]({repo_url}) | Run: {run_link}*
53+
</sub>
8054
"""
8155

8256
# Final safety check: sanitize comment body

0 commit comments

Comments
 (0)