Skip to content

Commit a2d20bb

Browse files
authored
Update leave-comment.yml
Signed-off-by: Aviv Keller <me@aviv.sh>
1 parent 827ce1d commit a2d20bb

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

.github/workflows/leave-comment.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ jobs:
6060
return;
6161
}
6262
63-
// 2. For forks that list is empty, so find the open Pull Request whose HEAD SHA matches
64-
// the commit that triggered the run.
65-
const pulls = await github.paginate(github.rest.pulls.list, {
63+
// 2. For forks that list is empty, so find the open Pull Request who has the
64+
// correct branch information
65+
const match = await github.rest.pulls.list({
6666
owner: context.repo.owner,
6767
repo: context.repo.repo,
68-
state: 'open',
69-
per_page: 100,
70-
});
71-
72-
const match = pulls.find(pull => pull.head.sha === run.head_sha);
68+
state: "open",
69+
head: `${context.payload.workflow_run.head_repository.owner.login}:${context.payload.workflow_run.head_branch}`,
70+
sort: "updated",
71+
direction: "desc",
72+
per_page: 1,
73+
}).then(r => r.data[0]);
7374
7475
if (!match) {
7576
core.info(`No open pull request found for HEAD ${run.head_sha}`);

0 commit comments

Comments
 (0)