Skip to content

Commit

Permalink
fix: fix updating comments
Browse files Browse the repository at this point in the history
Updating comments was broken when comments are created with a user other than the github-actions[bot] user.
  • Loading branch information
gmaclennan committed Oct 22, 2024
1 parent 6fded38 commit c7a69f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const { createTable, createSummary } = require('./comment')

const packageLockParser = new PackageLockParser()

const getCommentId = async (octokit, oktokitParams, issueNumber, commentHeader) => {
const COMMENT_IDENTIFIER = '<!-- npm-lockfile-changes-action comment -->'

const getCommentId = async (octokit, oktokitParams, issueNumber) => {
const currentComments = await octokit.rest.issues.listComments({
...oktokitParams,
issue_number: issueNumber,
Expand All @@ -23,9 +25,7 @@ const getCommentId = async (octokit, oktokitParams, issueNumber, commentHeader)
}

return currentComments.data
.filter(
({ user, body }) => user.login === 'github-actions[bot]' && body.startsWith(commentHeader)
)
.filter(({ body }) => body.includes(COMMENT_IDENTIFIER))
.map(({ id }) => id)[0]
}

Expand Down Expand Up @@ -123,7 +123,9 @@ const run = async () => {
'<summary>Click to toggle table visibility</summary>\n<br/>\n\n' +
diffsTable +
'\n\n' +
'</details>'
'</details>' +
'\n\n' +
COMMENT_IDENTIFIER

if (updateComment) {
if (commentId) {
Expand Down

0 comments on commit c7a69f0

Please sign in to comment.