Skip to content

Commit 88fb202

Browse files
authored
Merge pull request #514 from DataIntegrationGroup/BDMS-557-Implement-a-GitHub-Action-that-automatically-creates-a-corresponding-Jira-issue-whenever-a-new-GitHub-Issue-is-opened-in-selected-repositories
chore: enhance issue body formatting for Jira integration
2 parents e3456f5 + 7150e0d commit 88fb202

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

.github/workflows/jira_issue_on_open.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,32 @@ jobs:
5353
import os
5454
from pathlib import Path
5555
56+
def text_to_adf(text: str) -> dict:
57+
lines = text.splitlines()
58+
if not lines:
59+
lines = ["(No issue body provided)"]
60+
61+
content = []
62+
for idx, line in enumerate(lines):
63+
if line:
64+
content.append({"type": "text", "text": line})
65+
if idx < len(lines) - 1:
66+
content.append({"type": "hardBreak"})
67+
68+
if not content:
69+
content = [{"type": "text", "text": "(No issue body provided)"}]
70+
71+
return {
72+
"type": "doc",
73+
"version": 1,
74+
"content": [
75+
{
76+
"type": "paragraph",
77+
"content": content,
78+
}
79+
],
80+
}
81+
5682
issue_title = os.environ["ISSUE_TITLE"]
5783
issue_body = os.environ.get("ISSUE_BODY", "") or ""
5884
issue_url = os.environ["ISSUE_URL"]
@@ -86,7 +112,7 @@ jobs:
86112
if isinstance(override_fields, dict):
87113
custom_fields.update(override_fields)
88114
89-
description = (
115+
description_text = (
90116
f"GitHub issue: {issue_repo}#{issue_number}\\n"
91117
f"URL: {issue_url}\\n\\n"
92118
f"{issue_body if issue_body else '(No issue body provided)'}"
@@ -96,7 +122,7 @@ jobs:
96122
"project": {"key": os.environ["JIRA_PROJECT_KEY"]},
97123
"issuetype": {"name": os.environ["JIRA_ISSUE_TYPE"]},
98124
"summary": issue_title,
99-
"description": description,
125+
"description": text_to_adf(description_text),
100126
"labels": labels,
101127
}
102128
if components:

0 commit comments

Comments
 (0)