diff --git a/dist/index.js b/dist/index.js index d85692d..c02fb2c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -652,15 +652,17 @@ class AssemblyProcessor { * Do it in parallel so that we don't stop if one of them fails */ async commentStacks(comments, stageName, stage) { - const commentPromises = []; + const failed = []; for (const [stackName, comment] of Object.entries(stage.stackComments)) { - commentPromises.push(this.commentStack(comments, stageName, stackName, comment)); + try { + await this.commentStack(comments, stageName, stackName, comment); + } catch (e) { + failed.push(e); + } + // Rate limit: wait 200ms between API calls to avoid GitHub secondary rate limits + await new Promise(resolve => setTimeout(resolve, 200)); } - const res = await Promise.allSettled(commentPromises); - const failed = res - .filter((r) => r.status === 'rejected') - .flatMap((r) => r.reason); - if (failed && failed.length > 0) { + if (failed.length > 0) { throw new Error('Error commenting stacks: \n' + failed.join('\n')); } } @@ -695,6 +697,16 @@ class AssemblyProcessor { async commentStages(comments) { for (const [stageName, comment] of Object.entries(this.stageComments)) { const stageComment = this.getCommentForStage(stageName); + if (!stageComment.length) { + // No diffs detected for this stage - post a brief "no changes" comment + const noChangesComment = [`### Diff for stage: ${stageName}`, '', '✅ No changes detected.']; + try { + await this.commentStage(comments, comment.hash, noChangesComment); + } catch (e) { + // Ignore errors for no-change comments + } + continue; + } try { await this.commentStage(comments, comment.hash, stageComment); } @@ -750,7 +762,6 @@ class AssemblyProcessor { const output = []; const emoji = this.getEmoji(changes); if (diff.isEmpty) { - output.push(`No Changes for stack: ${stackName} ${emoji}`); return output; } output.push(...[