Skip to content
Closed
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
15 changes: 15 additions & 0 deletions .github/workflows/pull-request-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ jobs:
const fs = require( 'fs' );
const issue_number = Number( fs.readFileSync( './NR' ) );

core.info( `Checking pull request #${issue_number}.` );

// Confirm that the pull request is still open before leaving a comment.
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: issue_number,
});

if ( pr.data.state !== 'open' ) {
core.info( 'The pull request has been closed. No comment will be left.' );
return;
}

// Comments are only added after the first successful build. Check for the presence of a comment and bail early.
const commentInfo = {
owner: context.repo.owner,
Expand All @@ -141,6 +155,7 @@ jobs:

for ( const currentComment of comments ) {
if ( currentComment.user.type === 'Bot' && currentComment.body.includes( 'Test using WordPress Playground' ) ) {
core.info( 'A comment with instructions to test within a Playground instance already exists.' );
return;
}
};
Expand Down