Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set threshold #13

Merged
merged 8 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
issue_comment:
types: [created]

concurrency:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4

group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ inputs:
description:
'a target pr number. This is set for events triggered by issue_comment'
required: false
threshold:
description:
'a threshold at which a message is sent when the number of comments
exceeds this'
required: true
default: 4

# Define your outputs here.
outputs:
Expand Down
12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ export async function run(): Promise<void> {
})
).data.filter(c => c.user.type !== 'Bot')

const hasMessageSent = comments.some(
comment =>
comment.user?.type === 'Bot' &&
comment.body?.includes('It seems the discussion is dragging on.')
)
const threshold = Number(core.getInput('threshold', { required: true }))
const commentCount = comments.length + reviewComments.length
if (commentCount < threshold || hasMessageSent) {
core.debug('a message has been sent')
return
}

const userLogins = uniqueStringArray(
comments
.map(comment => comment.user?.login)
Expand Down
Loading