-
Notifications
You must be signed in to change notification settings - Fork 0
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
Send message to do mob programming #12
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
import * as core from '@actions/core' | ||
import { getOctokit, context } from '@actions/github' | ||
|
||
const uniqueStringArray = (texts: string[]): string[] => { | ||
if (texts.length === 0) return [] | ||
|
||
const sorted = texts.sort() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review comment |
||
const result = [sorted[0]] | ||
|
||
for (let i = 0; i < sorted.length - 1; i++) { | ||
if (sorted[i + 1] !== sorted[i]) { | ||
result.push(sorted[i + 1]) | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
/** | ||
* The main function for the action. | ||
* @returns {Promise<void>} Resolves when the action is complete. | ||
|
@@ -28,24 +43,32 @@ export async function run(): Promise<void> { | |
repo, | ||
issue_number: prNumber | ||
}) | ||
).data.filter(c => c.user?.type === 'Bot') | ||
).data.filter(c => c.user?.type !== 'Bot') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. three |
||
|
||
const reviewComments = ( | ||
await octokit.rest.pulls.listReviewComments({ | ||
owner, | ||
repo, | ||
pull_number: prNumber | ||
}) | ||
).data | ||
).data.filter(c => c.user.type !== 'Bot') | ||
|
||
const userLogins = uniqueStringArray( | ||
comments | ||
.map(comment => comment.user?.login) | ||
.concat(reviewComments.map(comment => comment.user.login)) | ||
.filter((comment): comment is string => !!comment) | ||
).map(login => `@${login}`) | ||
|
||
await octokit.rest.issues.createComment({ | ||
owner, | ||
repo, | ||
issue_number: prNumber, | ||
body: ` | ||
body: `Hey ${userLogins.join(', ')}! | ||
|
||
It seems the discussion is dragging on. Perhaps instead of text communication, you could try having a conversation via face-to-face or video call, or even try mob programming? | ||
|
||
the number of the comments is ${comments.length} | ||
the number of the review comments is ${reviewComments.length}` | ||
the number of the comments is ${comments.length} and the review comments is ${reviewComments.length}` | ||
}) | ||
core.debug(`Commented on PR #${prNumber}`) | ||
} catch (error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi