File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: Merge Conflict Notifier
22
33on :
44 schedule :
5- - cron : ' 0 * * * *'
5+ - cron : ' */5 * * * *'
66 workflow_dispatch :
77
88permissions :
@@ -76,20 +76,33 @@ jobs:
7676 });
7777 }
7878
79- // Check if we've already posted a conflict comment to avoid spam
79+ // Check existing comments to enforce a 2-hour notification gap
8080 const { data: comments } = await github.rest.issues.listComments({
8181 owner: context.repo.owner,
8282 repo: context.repo.repo,
8383 issue_number: pr.number,
8484 per_page: 100,
8585 });
8686
87- const alreadyCommented = comments.some (c =>
87+ const conflictComments = comments.filter (c =>
8888 c.user?.login === 'github-actions[bot]' &&
8989 c.body?.includes('merge conflicts with the main branch')
9090 );
9191
92- if (!alreadyCommented) {
92+ let shouldComment = false;
93+ if (conflictComments.length === 0) {
94+ shouldComment = true;
95+ } else {
96+ const lastComment = conflictComments[conflictComments.length - 1];
97+ const lastCommentTime = new Date(lastComment.created_at).getTime();
98+ const nowTime = new Date().getTime();
99+ const TWO_HOURS_MS = 2 * 60 * 60 * 1000;
100+ if (nowTime - lastCommentTime >= TWO_HOURS_MS) {
101+ shouldComment = true;
102+ }
103+ }
104+
105+ if (shouldComment) {
93106 await github.rest.issues.createComment({
94107 owner: context.repo.owner,
95108 repo: context.repo.repo,
You can’t perform that action at this time.
0 commit comments