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

Send message to do mob programming #12

Merged
merged 6 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 22 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 28 additions & 5 deletions src/main.ts
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[] => {
Copy link
Owner Author

Choose a reason for hiding this comment

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

hi

Copy link
Owner Author

Choose a reason for hiding this comment

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

hi

Copy link
Owner Author

Choose a reason for hiding this comment

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

hi

Copy link
Owner Author

Choose a reason for hiding this comment

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

hi

if (texts.length === 0) return []

const sorted = texts.sort()
Copy link
Owner Author

Choose a reason for hiding this comment

The 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.
Expand Down Expand Up @@ -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')
Copy link
Owner Author

Choose a reason for hiding this comment

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

one

Copy link
Owner Author

Choose a reason for hiding this comment

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

two

Copy link
Owner Author

Choose a reason for hiding this comment

The 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) {
Expand Down
Loading