Skip to content

Commit 6a972f9

Browse files
committed
fix(ci): use --body-file for GitHub comments
Problem: Multi-line comment bodies with shell variables cause parsing errors. Solution: Write comment body to file first, then use gh --body-file flag.
1 parent 4fc6984 commit 6a972f9

2 files changed

Lines changed: 83 additions & 59 deletions

File tree

.github/workflows/issue-triage.yml

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,20 @@ jobs:
225225
CLOSE_REASON: ${{ steps.parse.outputs.close_reason }}
226226
run: |
227227
ANALYSIS=$(cat /tmp/clio-workspace/analysis.json)
228-
SUMMARY=$(echo "$ANALYSIS" | jq -r '.summary // "Issue closed by automated triage."')
229228
230-
gh issue comment "$ISSUE_NUMBER" --body "## Automated Triage Result
231-
232-
This issue has been automatically closed.
233-
234-
**Reason:** ${CLOSE_REASON}
235-
236-
${SUMMARY}
237-
238-
If you believe this is incorrect, please reopen the issue with additional information."
229+
{
230+
echo "## Automated Triage Result"
231+
echo ""
232+
echo "This issue has been automatically closed."
233+
echo ""
234+
echo "**Reason:** ${CLOSE_REASON}"
235+
echo ""
236+
echo "$(echo "$ANALYSIS" | jq -r '.summary // "Issue closed by automated triage."')"
237+
echo ""
238+
echo "If you believe this is incorrect, please reopen the issue with additional information."
239+
} > /tmp/clio-workspace/close_comment.md
239240
241+
gh issue comment "$ISSUE_NUMBER" --body-file /tmp/clio-workspace/close_comment.md
240242
gh issue close "$ISSUE_NUMBER" --reason "not planned" 2>/dev/null || gh issue close "$ISSUE_NUMBER"
241243
242244
- name: Handle needs-info recommendation
@@ -246,18 +248,19 @@ jobs:
246248
ISSUE_NUMBER: ${{ github.event.issue.number }}
247249
run: |
248250
ANALYSIS=$(cat /tmp/clio-workspace/analysis.json)
249-
MISSING=$(echo "$ANALYSIS" | jq -r '(.missing_info // []) | map("- " + .) | join("\n")' || echo "- Additional details needed")
250-
SUMMARY=$(echo "$ANALYSIS" | jq -r '.summary // "More information is needed to process this issue."')
251251
252-
gh issue comment "$ISSUE_NUMBER" --body "## More Information Needed
253-
254-
${SUMMARY}
255-
256-
**Please provide:**
257-
${MISSING}
258-
259-
Once you've added this information, the issue will be re-evaluated."
252+
{
253+
echo "## More Information Needed"
254+
echo ""
255+
echo "$(echo "$ANALYSIS" | jq -r '.summary // "More information is needed to process this issue."')"
256+
echo ""
257+
echo "**Please provide:**"
258+
echo "$ANALYSIS" | jq -r '(.missing_info // ["Additional details needed"])[] | "- " + .'
259+
echo ""
260+
echo "Once you've added this information, the issue will be re-evaluated."
261+
} > /tmp/clio-workspace/needs_info_comment.md
260262
263+
gh issue comment "$ISSUE_NUMBER" --body-file /tmp/clio-workspace/needs_info_comment.md
261264
gh issue edit "$ISSUE_NUMBER" --add-label "needs-info" 2>/dev/null || \
262265
(gh label create "needs-info" --color "d876e3" --description "Awaiting more information from reporter" 2>/dev/null; gh issue edit "$ISSUE_NUMBER" --add-label "needs-info") || true
263266
@@ -268,22 +271,25 @@ jobs:
268271
ISSUE_NUMBER: ${{ github.event.issue.number }}
269272
run: |
270273
ANALYSIS=$(cat /tmp/clio-workspace/analysis.json)
271-
SUMMARY=$(echo "$ANALYSIS" | jq -r '.summary // "Issue triaged successfully."')
272274
CLASSIFICATION=$(echo "$ANALYSIS" | jq -r '.classification // "unknown"')
273275
PRIORITY=$(echo "$ANALYSIS" | jq -r '.priority // "medium"')
274276
COMPLETENESS=$(echo "$ANALYSIS" | jq -r '.completeness // "N/A"')
275277
276-
gh issue comment "$ISSUE_NUMBER" --body "## Automated Triage Summary
277-
278-
| Field | Value |
279-
|-------|-------|
280-
| Classification | \`${CLASSIFICATION}\` |
281-
| Priority | \`${PRIORITY}\` |
282-
| Completeness | ${COMPLETENESS}% |
283-
284-
**Analysis:** ${SUMMARY}
285-
286-
_This is an automated analysis. A maintainer will review shortly._"
278+
{
279+
echo "## Automated Triage Summary"
280+
echo ""
281+
echo "| Field | Value |"
282+
echo "|-------|-------|"
283+
echo "| Classification | \`${CLASSIFICATION}\` |"
284+
echo "| Priority | \`${PRIORITY}\` |"
285+
echo "| Completeness | ${COMPLETENESS}% |"
286+
echo ""
287+
echo "**Analysis:** $(echo "$ANALYSIS" | jq -r '.summary // "Issue triaged successfully."')"
288+
echo ""
289+
echo "_This is an automated analysis. A maintainer will review shortly._"
290+
} > /tmp/clio-workspace/triage_comment.md
291+
292+
gh issue comment "$ISSUE_NUMBER" --body-file /tmp/clio-workspace/triage_comment.md
287293
288294
- name: Upload artifacts
289295
if: always()
@@ -296,4 +302,5 @@ jobs:
296302
/tmp/clio-workspace/analysis.json
297303
/tmp/clio-workspace/ISSUE_INFO.md
298304
/tmp/clio-workspace/ISSUE_BODY.md
305+
/tmp/clio-workspace/*.md
299306
retention-days: 7

.github/workflows/pr-review.yml

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ jobs:
180180
run: |
181181
ANALYSIS=$(cat /tmp/clio-workspace/analysis.json)
182182
RECOMMENDATION=$(echo "$ANALYSIS" | jq -r '.recommendation // "needs-review"')
183-
SUMMARY=$(echo "$ANALYSIS" | jq -r '.summary // "Analysis complete."')
184183
TEST_COV=$(echo "$ANALYSIS" | jq -r '.test_coverage // "unknown"')
185184
BREAKING=$(echo "$ANALYSIS" | jq -r '.breaking_changes // false')
186185
@@ -191,33 +190,50 @@ jobs:
191190
*) EMOJI="INFO"; VERDICT="Needs Review" ;;
192191
esac
193192
194-
# Build security concerns section
195-
SEC_CONCERNS=$(echo "$ANALYSIS" | jq -r '(.security_concerns // []) | if length > 0 then "## Security Concerns\n\n" + (map("- " + .) | join("\n")) + "\n" else "" end')
196-
197-
# Build style issues section
198-
STYLE_ISSUES=$(echo "$ANALYSIS" | jq -r '(.style_issues // []) | if length > 0 then "## Style Issues\n\n" + (map("- " + .) | join("\n")) + "\n" else "" end')
199-
200-
# Build detailed feedback section
201-
FEEDBACK=$(echo "$ANALYSIS" | jq -r '(.detailed_feedback // []) | if length > 0 then "## Detailed Feedback\n\n" + (map("- " + .) | join("\n")) + "\n" else "" end')
202-
203-
# Construct comment body
204-
COMMENT_BODY="## ${EMOJI} CLIO Automated Review: ${VERDICT}
205-
206-
**Summary:** ${SUMMARY}
207-
208-
| Metric | Value |
209-
|--------|-------|
210-
| Test Coverage | \`${TEST_COV}\` |
211-
| Breaking Changes | \`${BREAKING}\` |
212-
213-
${SEC_CONCERNS}
214-
${STYLE_ISSUES}
215-
${FEEDBACK}
216-
217-
---
218-
_This is an automated review. A human maintainer will provide final approval._"
193+
# Build comment body to a file using jq to safely handle content
194+
{
195+
echo "## ${EMOJI} CLIO Automated Review: ${VERDICT}"
196+
echo ""
197+
echo "**Summary:** $(echo "$ANALYSIS" | jq -r '.summary // "Analysis complete."')"
198+
echo ""
199+
echo "| Metric | Value |"
200+
echo "|--------|-------|"
201+
echo "| Test Coverage | \`${TEST_COV}\` |"
202+
echo "| Breaking Changes | \`${BREAKING}\` |"
203+
echo ""
204+
205+
# Security concerns
206+
SEC_COUNT=$(echo "$ANALYSIS" | jq -r '(.security_concerns // []) | length')
207+
if [ "$SEC_COUNT" -gt 0 ]; then
208+
echo "## Security Concerns"
209+
echo ""
210+
echo "$ANALYSIS" | jq -r '(.security_concerns // [])[] | "- " + .'
211+
echo ""
212+
fi
213+
214+
# Style issues
215+
STYLE_COUNT=$(echo "$ANALYSIS" | jq -r '(.style_issues // []) | length')
216+
if [ "$STYLE_COUNT" -gt 0 ]; then
217+
echo "## Style Issues"
218+
echo ""
219+
echo "$ANALYSIS" | jq -r '(.style_issues // [])[] | "- " + .'
220+
echo ""
221+
fi
222+
223+
# Detailed feedback
224+
FB_COUNT=$(echo "$ANALYSIS" | jq -r '(.detailed_feedback // []) | length')
225+
if [ "$FB_COUNT" -gt 0 ]; then
226+
echo "## Detailed Feedback"
227+
echo ""
228+
echo "$ANALYSIS" | jq -r '(.detailed_feedback // [])[] | "- " + .'
229+
echo ""
230+
fi
231+
232+
echo "---"
233+
echo "_This is an automated review. A human maintainer will provide final approval._"
234+
} > /tmp/clio-workspace/comment.md
219235
220-
gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY"
236+
gh pr comment "$PR_NUMBER" --body-file /tmp/clio-workspace/comment.md
221237
222238
- name: Upload artifacts
223239
if: always()
@@ -230,4 +246,5 @@ _This is an automated review. A human maintainer will provide final approval._"
230246
/tmp/clio-workspace/analysis.json
231247
/tmp/clio-workspace/PR_INFO.md
232248
/tmp/clio-workspace/PR_DIFF.txt
249+
/tmp/clio-workspace/comment.md
233250
retention-days: 7

0 commit comments

Comments
 (0)