Skip to content

Commit 6182c8b

Browse files
authored
Merge pull request #1077 from 0xPolygonHermez/fix/ct-com
fix(ci): Filtering PRs by head instead of being local
2 parents 9b0af82 + 1691627 commit 6182c8b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

.github/workflows/cycle-tracking-comment.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ jobs:
4242
// Derive the target PR from the trusted workflow_run payload.
4343
let prNumber = run.pull_requests?.[0]?.number;
4444
if (!prNumber) {
45-
// Fork PRs: workflow_run.pull_requests is empty, so resolve the PR
46-
// from the head commit SHA.
47-
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
45+
const headOwner = run.head_repository?.owner?.login ?? context.repo.owner;
46+
const { data: prs } = await github.rest.pulls.list({
4847
owner: context.repo.owner,
4948
repo: context.repo.repo,
50-
commit_sha: run.head_sha,
49+
state: 'all',
50+
head: `${headOwner}:${run.head_branch}`,
5151
});
52-
prNumber = prs.find((p) => p.state === 'open')?.number;
52+
prNumber = (prs.find((p) => p.head?.sha === run.head_sha) ?? prs[0])?.number;
5353
}
5454
if (!Number.isInteger(prNumber)) {
5555
core.setFailed(`Could not resolve a PR for workflow_run ${run.id} (head_sha ${run.head_sha})`);

0 commit comments

Comments
 (0)