Skip to content

Commit 72f0719

Browse files
delucis43081j
andauthored
Update existing comment if no issues found (#122)
* Update existing comment if no issues found * analysis! 🧑‍🔬 Co-authored-by: James Garbutt <43081j@users.noreply.github.com> --------- Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
1 parent 71db11f commit 72f0719

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/main.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,6 @@ async function run(): Promise<void> {
212212
scanForReplacements(messages, baseDependencies, currentDependencies);
213213
}
214214

215-
// Skip comment creation/update if there are no messages
216-
if (messages.length === 0) {
217-
core.info('No dependency warnings found. Skipping comment creation.');
218-
return;
219-
}
220-
221215
const octokit = github.getOctokit(token);
222216
let existingCommentId: number | undefined = undefined;
223217

@@ -244,6 +238,24 @@ async function run(): Promise<void> {
244238
}
245239
}
246240

241+
// Skip comment creation if there are no messages or update the existing comment.
242+
if (messages.length === 0) {
243+
if (existingCommentId) {
244+
await octokit.rest.issues.updateComment({
245+
owner: github.context.repo.owner,
246+
repo: github.context.repo.repo,
247+
comment_id: existingCommentId,
248+
body: `${COMMENT_TAG}\n## e18e dependency analysis\n\nNo dependency warnings found.\n`
249+
});
250+
core.info(
251+
`Updated existing dependency diff comment #${existingCommentId}`
252+
);
253+
} else {
254+
core.info('No dependency warnings found. Skipping comment creation.');
255+
}
256+
return;
257+
}
258+
247259
const finalCommentBody = `${COMMENT_TAG}\n${messages.join('\n\n')}`;
248260

249261
if (existingCommentId) {

0 commit comments

Comments
 (0)