Skip to content

Commit ef32a8c

Browse files
committed
Build/Test Tools: Only open pull requests need testing instructions.
This adds some logic to avoid leaving automated comments with instructions to test in Playground when the pull request has been closed. Props jeffpaul. See #63170. git-svn-id: https://develop.svn.wordpress.org/trunk@61135 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 68ea410 commit ef32a8c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.github/workflows/pull-request-comments.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ jobs:
130130
const fs = require( 'fs' );
131131
const issue_number = Number( fs.readFileSync( './NR' ) );
132132
133+
core.info( `Checking pull request #${issue_number}.` );
134+
135+
// Confirm that the pull request is still open before leaving a comment.
136+
const pr = await github.rest.pulls.get({
137+
owner: context.repo.owner,
138+
repo: context.repo.repo,
139+
pull_number: issue_number,
140+
});
141+
142+
if ( pr.data.state !== 'open' ) {
143+
core.info( 'The pull request has been closed. No comment will be left.' );
144+
return;
145+
}
146+
133147
// Comments are only added after the first successful build. Check for the presence of a comment and bail early.
134148
const commentInfo = {
135149
owner: context.repo.owner,
@@ -141,6 +155,7 @@ jobs:
141155
142156
for ( const currentComment of comments ) {
143157
if ( currentComment.user.type === 'Bot' && currentComment.body.includes( 'Test using WordPress Playground' ) ) {
158+
core.info( 'A comment with instructions to test within a Playground instance already exists.' );
144159
return;
145160
}
146161
};

0 commit comments

Comments
 (0)