From 7b815c10cf9479e2c63fab5c4d8c342ca2d8a5a0 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 30 Oct 2025 23:38:09 -0400 Subject: [PATCH 1/2] Avoid leaving Playground comment on closed PRs --- .github/workflows/pull-request-comments.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/pull-request-comments.yml b/.github/workflows/pull-request-comments.yml index 799f2d04c107c..5be750727fe21 100644 --- a/.github/workflows/pull-request-comments.yml +++ b/.github/workflows/pull-request-comments.yml @@ -130,6 +130,18 @@ jobs: const fs = require( 'fs' ); const issue_number = Number( fs.readFileSync( './NR' ) ); + // Confirm that the pull request is still open. + 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.' ); + 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, @@ -141,6 +153,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 for how to test in Playground already exists.' ); return; } }; From 98c5c279583b81cdff310385408e66fde2466265 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Tue, 4 Nov 2025 10:32:34 -0500 Subject: [PATCH 2/2] Improve some messaging text. --- .github/workflows/pull-request-comments.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request-comments.yml b/.github/workflows/pull-request-comments.yml index 5be750727fe21..6611309bd3047 100644 --- a/.github/workflows/pull-request-comments.yml +++ b/.github/workflows/pull-request-comments.yml @@ -130,7 +130,9 @@ jobs: const fs = require( 'fs' ); const issue_number = Number( fs.readFileSync( './NR' ) ); - // Confirm that the pull request is still open. + 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, @@ -138,7 +140,7 @@ jobs: }); if ( pr.data.state !== 'open' ) { - core.info( 'The pull request has been closed.' ); + core.info( 'The pull request has been closed. No comment will be left.' ); return; } @@ -153,7 +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 for how to test in Playground already exists.' ); + core.info( 'A comment with instructions to test within a Playground instance already exists.' ); return; } };