Skip to content

Prevent @radashi-bot from commenting on PR that already has a pre-release #420

@aleclarson

Description

@aleclarson

When publishing another pre-release, @radashi-bot should not comment on PRs that already had their first pre-release. But it should comment when a stable release is published (which it already does).

If anyone has time to look into this, here's the related code:

// Find and delete existing comment by radashi-bot
const existingComments = await octokit.issues.listComments({
owner: 'radashi-org',
repo: 'radashi',
issue_number: +prNumber,
per_page: 100,
})
const botComment = existingComments.data.find(
comment =>
comment.user &&
(comment.user.login === 'radashi-bot' ||
comment.user.login === 'github-actions[bot]') &&
comment.body?.includes('published to NPM'),
)
if (botComment) {
await octokit.issues.deleteComment({
owner: 'radashi-org',
repo: 'radashi',
comment_id: botComment.id,
})
}
// Create new comment
await octokit.issues.createComment({
owner: 'radashi-org',
repo: 'radashi',
issue_number: +prNumber,
body,
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceAn improvement to codebase maintainability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions