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

Always create new comment for visibility #125

Closed
wants to merge 1 commit into from
Closed
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
26 changes: 10 additions & 16 deletions dist/index.js

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

26 changes: 10 additions & 16 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,6 @@ export default class GitHub {
commentMessage +=
"**To understand the WordPress project's expectations around crediting contributors, please [review the Contributor Attribution page in the Core Handbook](https://make.wordpress.org/core/handbook/best-practices/contributor-attribution-props/).**\n";

const comment = {
...commentInfo,
body: commentMessage,
};

for await ( const response of this.octokit.paginate.iterator(
this.octokit.rest.issues.listComments,
commentInfo
Expand All @@ -248,28 +243,27 @@ export default class GitHub {
}

if ( commentId ) {
core.info( `Updating previous comment #${ commentId }` );
core.info( `Deleting previous comment #${ commentId }` );

try {
await this.octokit.rest.issues.updateComment( {
await this.octokit.rest.issues.deleteComment( {
...context.repo,
comment_id: commentId,
body: comment.body,
} );
} catch ( e ) {
core.info( 'Error editing previous comment: ' + e.message );
commentId = null;
}
}

// No previous or edit comment failed.
if ( ! commentId ) {
core.info( 'No previous comment found. Creating a new one.' );
try {
await this.octokit.rest.issues.createComment( comment );
} catch ( e ) {
core.error( `Error creating comment: ${ e.message }` );
}
core.info( 'Creating a new comment.' );
try {
await this.octokit.rest.issues.createComment( {
...commentInfo,
body: commentMessage,
} );
} catch ( e ) {
core.error( `Error creating comment: ${ e.message }` );
}
}
}
Loading