Skip to content

Commit 7f736be

Browse files
nicohrubeccodex
andcommitted
fix(ci): Avoid duplicate bundle size failure comments
Co-Authored-By: GPT-6 <codex@openai.com>
1 parent 8900460 commit 7f736be

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

‎dev-packages/size-limit-gh-action/index.mjs‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ const RESULTS_FILE_PATH = path.join(ACTION_DIRECTORY, 'size-limit-results.json')
1818

1919
const { getInput, setFailed } = core;
2020

21-
async function fetchPreviousComment(octokit, repo, pr) {
22-
const { data: commentList } = await octokit.rest.issues.listComments({
23-
...repo,
24-
issue_number: pr.number,
25-
});
26-
27-
const sizeLimitComment = commentList.find(comment => comment.body.startsWith(SIZE_LIMIT_HEADING));
28-
return !sizeLimitComment ? null : sizeLimitComment;
29-
}
30-
3121
async function run() {
3222
try {
3323
const { payload, repo } = context;
@@ -133,7 +123,12 @@ async function run() {
133123
await core.summary.addRaw(body).write();
134124

135125
try {
136-
const sizeLimitComment = await fetchPreviousComment(octokit, repo, pr);
126+
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
127+
...repo,
128+
issue_number: pr.number,
129+
per_page: 100,
130+
});
131+
const sizeLimitComment = comments.find(comment => comment.body.startsWith(SIZE_LIMIT_HEADING));
137132
if (sizeLimitComment) {
138133
await octokit.rest.issues.updateComment({
139134
...repo,
@@ -148,7 +143,7 @@ async function run() {
148143
});
149144
}
150145

151-
if (increases.length > 0 && !approved) {
146+
if (increases.length > 0 && !approved && !comments.some(comment => comment.body === failure)) {
152147
await octokit.rest.issues.createComment({
153148
...repo,
154149
issue_number: pr.number,

0 commit comments

Comments
 (0)