Skip to content

Commit

Permalink
Fix duplicated comment on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWoo committed Sep 29, 2024
1 parent bab8418 commit 86c74a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
private_key = private_key_part_1 + private_key_part_2

def comment_on_pr(content, title):
print("content:", content)
print(f"content: {content}, title: {title}")
if content is None:
raise Exception("Content is required")

Expand All @@ -68,18 +68,16 @@ def comment_on_pr(content, title):
comments = pull_request.get_issue_comments()

# Check if a comment by raftkeepeer-robot[bot] exists
comment_found = False
for comment in comments:
print("find comment:", comment)
if comment.user.login == "raftkeepeer-robot[bot]" and title in comment.body:
# print(f"find comment for {comment.user.login}")
# print(f"comment body: {comment.body}")
if comment.user.login == "raftkeeper-robot[bot]" and title in comment.body:
# Update the existing comment
comment.edit(content)
comment_found = True
break
return

# If not, create a new comment
if not comment_found:
pull_request.create_issue_comment(content)
pull_request.create_issue_comment(content)


def get_artifact_url(artifact_name):
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ def report(report_dir, report_type):
else:
raise ValueError('Integration test report not available')

title_prefix_copy = title_prefix
content = generate_report(report_dir, title_prefix)
if content is not None:
comment_on_pr(content, title_prefix_copy)
comment_on_pr(content, title_prefix)


if __name__ == "__main__":
Expand Down

0 comments on commit 86c74a4

Please sign in to comment.