Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions .github/workflows/claude-documentation-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,33 @@ jobs:

FOOTER_MARKER = "Automated fixes are only available"

def normalize_body(body):
"""Strip any intro text before the ## Preexisting issues header."""
idx = body.find('## Preexisting issues')
if idx > 0:
body = body[idx:]
return body.strip()

def patch_comment(comment_id, new_body):
payload = {'body': new_body}
subprocess.run(
['gh', 'api', f'repos/{repo}/issues/comments/{comment_id}',
'-X', 'PATCH', '--input', '-'],
input=json.dumps(payload),
capture_output=True, text=True, check=True,
)

summary_path = '/tmp/preexisting-issues.md'
if os.path.exists(summary_path):
# Claude wrote to the file as instructed — post a new comment with footer
with open(summary_path) as f:
body = f.read().strip()
body = normalize_body(f.read())
subprocess.run(
['gh', 'pr', 'comment', pr_number, '--repo', repo, '--body', body + FOOTER],
check=True,
)
else:
# Claude posted directly — find that comment and edit it to add the footer
# Claude posted directly — find that comment, strip any intro, and add the footer
result = subprocess.run(
['gh', 'api', f'repos/{repo}/issues/{pr_number}/comments',
'--jq', '[.[] | select(.user.login == "github-actions[bot]")]'],
Expand All @@ -130,10 +146,6 @@ jobs:
for comment in reversed(comments):
body = comment['body']
if '## Preexisting issues' in body and FOOTER_MARKER not in body:
subprocess.run(
['gh', 'api', f'repos/{repo}/issues/comments/{comment["id"]}',
'-X', 'PATCH', '-f', f'body={body.rstrip()}{FOOTER}'],
check=True,
)
patch_comment(comment['id'], normalize_body(body) + FOOTER)
break
PYTHON_EOF
Loading