Skip to content

Commit cc5becb

Browse files
committed
Close PR after comment But check it's open first.
Fixes #62811. git-svn-id: https://develop.svn.wordpress.org/trunk@59634 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1befbb4 commit cc5becb

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

.github/workflows/close-pulls.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,38 @@ jobs:
6868
with:
6969
script: |
7070
const prNumbers = ${{ steps.pr-results.outputs.result }};
71-
const commentBody = `A commit was made that fixes a Trac ticket referenced in the description of this pull request.
7271
73-
SVN changeset: [${{ steps.git-svn-id.outputs.svn_revision_number }}](https://core.trac.wordpress.org/changeset/${{ steps.git-svn-id.outputs.svn_revision_number }})
74-
GitHub changeset: ${{ github.sha }}
72+
for (const prNumber of prNumbers) {
73+
const pr = await github.rest.pulls.get({
74+
owner: 'desrosj',
75+
repo: 'wordpress-develop',
76+
pull_number: 155
77+
});
7578
76-
This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.`;
79+
if ( pr.data.state === 'closed' ) {
80+
continue;
81+
}
7782
78-
for (const prNumber of prNumbers) {
83+
const commentBody = `A commit was made that fixes a Trac ticket referenced in the description of this pull request.
84+
85+
SVN changeset: [${{ steps.git-svn-id.outputs.svn_revision_number }}](https://core.trac.wordpress.org/changeset/${{ steps.git-svn-id.outputs.svn_revision_number }})
86+
GitHub changeset: ${{ github.sha }}
87+
88+
This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.`;
89+
90+
// Comment on the pull request with details.
7991
await github.rest.issues.createComment({
8092
owner: 'desrosj',
8193
repo: 'wordpress-develop',
8294
issue_number: 155,
8395
body: commentBody
8496
});
97+
98+
// Close the pull request.
99+
await github.rest.pulls.update({
100+
owner: 'desrosj',
101+
repo: 'wordpress-develop',
102+
pull_number: 155,
103+
state: 'closed'
104+
});
85105
}

0 commit comments

Comments
 (0)