From 7edec33931e0ad33a50bccea51ca71dab0215f3d Mon Sep 17 00:00:00 2001 From: shravanngoswamii <123811742+shravanngoswamii@users.noreply.github.com> Date: Thu, 26 Mar 2026 14:44:51 +0000 Subject: [PATCH] Fix SyncPRSummary action bot comments scanning and redundant API calls Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- SyncPRSummary/action.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/SyncPRSummary/action.yml b/SyncPRSummary/action.yml index a0f6d67..bed68b1 100644 --- a/SyncPRSummary/action.yml +++ b/SyncPRSummary/action.yml @@ -33,6 +33,7 @@ runs: }, { key: "perf", + marker: "", title: "Performance", input: (process.env.INPUT_PERF_CONTENT ?? "").trim(), fallback: "_Pending. No performance results available yet._", @@ -72,16 +73,36 @@ runs: const managedBody = managedComment?.body ?? ""; - const resolvedSections = SECTIONS.map(({ key, title, input, fallback }) => ({ + const latestByMarker = new Map(); + for (const comment of allComments) { + const body = comment.body || ""; + const user = comment.user?.login; + const app = comment.performed_via_github_app?.slug; + const isBot = user === "github-actions[bot]" || app === "github-actions"; + if (!isBot) continue; + + for (const { marker, title } of SECTIONS) { + if (!marker) continue; + if (!body.startsWith(marker)) continue; + const content = body.slice(marker.length).trim(); + if (content) latestByMarker.set(marker, content); + } + } + + const resolvedSections = SECTIONS.map(({ key, marker, title, input, fallback }) => ({ key, title, - content: input || readSection(managedBody, key) || fallback, + content: input || latestByMarker.get(marker) || readSection(managedBody, key) || fallback, })); const newBody = buildBody(resolvedSections); if (managedComment) { - await github.rest.issues.updateComment({ owner, repo, comment_id: managedComment.id, body: newBody }); + if (managedComment.body !== newBody) { + await github.rest.issues.updateComment({ owner, repo, comment_id: managedComment.id, body: newBody }); + } else { + core.info("PR summary already up to date."); + } } else { await github.rest.issues.createComment({ owner, repo, issue_number: prNumber, body: newBody }); }