Skip to content

Commit

Permalink
fix(workflow): chore duplicate comment ratelimit
Browse files Browse the repository at this point in the history
  • Loading branch information
dinxsh authored Sep 12, 2024
1 parent c32a29f commit 5a89e37
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/allcontributor_autocommentor_active_issue.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Comment on Active "Add Profile" Issues
name: Comment on Active Add Profile Issues

on:
workflow_dispatch:
schedule:
- cron: '0 */3 * * *'
- cron: '0 */6 * * *'

jobs:
comment-on-active-issues:
Expand All @@ -27,13 +27,27 @@ jobs:
const issueCreator = issue.user.login;
const commentMessage = `@all-contributors please add @${issueCreator} for review`;
await github.rest.issues.createComment({
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: commentMessage
issue_number: issue.number
});
console.log(`Commented on issue #${issue.number}`);
const hasAllContributorsComment = comments.some(comment =>
comment.body.includes('@all-contributors please add')
);
if (!hasAllContributorsComment) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: commentMessage
});
console.log(`Commented on issue #${issue.number}`);
} else {
console.log(`Skipped commenting on issue #${issue.number} - already has an all-contributors comment`);
}
}
}

0 comments on commit 5a89e37

Please sign in to comment.