Skip to content
Draft
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
51 changes: 30 additions & 21 deletions ref-comment-in-commit/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30939,7 +30939,7 @@ if (!commits?.length) {
} else {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Commits: ${commits.length}`)
await Promise.all(
commits.map(async ({ sha, commit: { message } }) => {
commits.map(async ({ sha, commit: { message, author } }) => {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.debug(`Commit message:${`\n${message}`.replace('\n', '\n\t')}`)

const urls =
Expand All @@ -30949,27 +30949,36 @@ if (!commits?.length) {

_actions_core__WEBPACK_IMPORTED_MODULE_0__.debug(`Discussion URLs: ${urls.length}`)

await Promise.all(
urls
.map((url) => new URL(url))
.map((url) => ({
url,
owner: url.pathname.split('/').at(1),
repo: url.pathname.split('/').at(2),
prNumber: Number(url.pathname.split('/').at(-1)),
commentId: Number(url.hash.replace('#discussion_r', '')),
}))
.map(async ({ url, owner, repo, prNumber, commentId }) => {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Posting reply to ${url.toString()}`)
octokit.rest.pulls.createReplyForReviewComment({
owner,
repo,
pull_number: prNumber,
comment_id: commentId,
body: `Referenced in ${sha}`,
if (urls.length > 0) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.debug('Getting author info')
const { data: authorUser } = await octokit.rest.users.getByEmail({
email: author.email,
})

const authorMarkdown = authorUser ? `@${author.name}` : author.name

await Promise.all(
urls
.map((url) => new URL(url))
.map((url) => ({
url,
owner: url.pathname.split('/').at(1),
repo: url.pathname.split('/').at(2),
prNumber: Number(url.pathname.split('/').at(-1)),
commentId: Number(url.hash.replace('#discussion_r', '')),
}))
.map(async ({ url, owner, repo, prNumber, commentId }) => {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Posting reply to ${url.toString()}`)
octokit.rest.pulls.createReplyForReviewComment({
owner,
repo,
pull_number: prNumber,
comment_id: commentId,
body: `Referenced in ${sha} by ${authorMarkdown}:\n\n\`\`\`\n${message}\n\`\`\``,
})
})
})
)
)
}
})
)
}
Expand Down
51 changes: 30 additions & 21 deletions ref-comment-in-commit/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (!commits?.length) {
} else {
core.info(`Commits: ${commits.length}`)
await Promise.all(
commits.map(async ({ sha, commit: { message } }) => {
commits.map(async ({ sha, commit: { message, author } }) => {
core.debug(`Commit message:${`\n${message}`.replace('\n', '\n\t')}`)

const urls =
Expand All @@ -55,27 +55,36 @@ if (!commits?.length) {

core.debug(`Discussion URLs: ${urls.length}`)

await Promise.all(
urls
.map((url) => new URL(url))
.map((url) => ({
url,
owner: url.pathname.split('/').at(1),
repo: url.pathname.split('/').at(2),
prNumber: Number(url.pathname.split('/').at(-1)),
commentId: Number(url.hash.replace('#discussion_r', '')),
}))
.map(async ({ url, owner, repo, prNumber, commentId }) => {
core.info(`Posting reply to ${url.toString()}`)
octokit.rest.pulls.createReplyForReviewComment({
owner,
repo,
pull_number: prNumber,
comment_id: commentId,
body: `Referenced in ${sha}`,
if (urls.length > 0) {
core.debug('Getting author info')
const { data: authorUser } = await octokit.rest.users.getByEmail({
email: author.email,
})

const authorMarkdown = authorUser ? `@${author.name}` : author.name

await Promise.all(
urls
.map((url) => new URL(url))
.map((url) => ({
url,
owner: url.pathname.split('/').at(1),
repo: url.pathname.split('/').at(2),
prNumber: Number(url.pathname.split('/').at(-1)),
commentId: Number(url.hash.replace('#discussion_r', '')),
}))
.map(async ({ url, owner, repo, prNumber, commentId }) => {
core.info(`Posting reply to ${url.toString()}`)
octokit.rest.pulls.createReplyForReviewComment({
owner,
repo,
pull_number: prNumber,
comment_id: commentId,
body: `Referenced in ${sha} by ${authorMarkdown}:\n\n\`\`\`\n${message}\n\`\`\``,
})
})
})
)
)
}
})
)
}