Skip to content

Commit ad02bef

Browse files
committed
ci: Fix comment handling
Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 88a1ef4 commit ad02bef

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

.github/workflows/module-monitor.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -388,20 +388,29 @@ jobs:
388388
(process.env.blob_summary || '') + '\n\n' +
389389
'This comment was automatically generated.';
390390
391-
if (existingComment) {
392-
await github.rest.issues.updateComment({
393-
owner: context.repo.owner,
394-
repo: context.repo.repo,
395-
comment_id: existingComment.id,
396-
body: commentBody
397-
});
398-
} else {
399-
await github.rest.issues.createComment({
400-
owner: context.repo.owner,
401-
repo: context.repo.repo,
402-
issue_number: context.issue.number,
403-
body: commentBody
404-
});
391+
try {
392+
if (existingComment) {
393+
await github.rest.issues.updateComment({
394+
owner: context.repo.owner,
395+
repo: context.repo.repo,
396+
comment_id: existingComment.id,
397+
body: commentBody
398+
});
399+
console.log('Successfully updated existing comment');
400+
} else {
401+
await github.rest.issues.createComment({
402+
owner: context.repo.owner,
403+
repo: context.repo.repo,
404+
issue_number: context.issue.number,
405+
body: commentBody
406+
});
407+
console.log('Successfully created new comment');
408+
}
409+
} catch (error) {
410+
console.log('Could not create/update comment due to permissions. This is normal for forks.');
411+
console.log('Error:', error.message);
412+
console.log('Comment body that would have been posted:');
413+
console.log(commentBody);
405414
}
406415
env:
407416
diff_output: ${{ steps.set-output.outputs.diff_output }}

0 commit comments

Comments
 (0)