diff --git a/ref-comment-in-commit/dist/index.mjs b/ref-comment-in-commit/dist/index.mjs index 137aeaa0..3fd62f0f 100644 --- a/ref-comment-in-commit/dist/index.mjs +++ b/ref-comment-in-commit/dist/index.mjs @@ -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 = @@ -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\`\`\``, + }) }) - }) - ) + ) + } }) ) } diff --git a/ref-comment-in-commit/index.mjs b/ref-comment-in-commit/index.mjs index e776bf31..ade9591a 100644 --- a/ref-comment-in-commit/index.mjs +++ b/ref-comment-in-commit/index.mjs @@ -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 = @@ -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\`\`\``, + }) }) - }) - ) + ) + } }) ) }