TypeScript
fix(ci): fork PRs now resolve in workflow_run PR lookups (#26779)
Julius Marminge783581d461dc
diff --git a/.github/workflows/desktop-macos-preview-publish.yml b/.github/workflows/desktop-macos-preview-publish.ymlindex bd6f59bc0f0..6e8805b7f79 100644--- a/.github/workflows/desktop-macos-preview-publish.yml+++ b/.github/workflows/desktop-macos-preview-publish.yml@@ -77,16 +77,19 @@ jobs:return;}- // workflow_run.pull_requests is empty for fork PRs, so resolve the- // PR from the built commit instead and require exactly one open PR- // from the same head repository and branch. The build baked its+ // workflow_run.pull_requests and the commit-to-PR lookup are both+ // empty for fork PRs, so list open PRs by head owner and branch+ // and require exactly one at the built commit. The build baked its// PR number into the version, so two candidates would mean the// asset name could belong to either.- const associated = await github.paginate(- github.rest.repos.listPullRequestsAssociatedWithCommit,- { owner, repo, commit_sha: run.head_sha, per_page: 100 },- );- const matching = associated.filter(+ const open = await github.paginate(github.rest.pulls.list, {+ owner,+ repo,+ state: "open",+ head: `${run.head_repository?.owner?.login}:${run.head_branch}`,+ per_page: 100,+ });+ const matching = open.filter((candidate) =>candidate.state === "open" &&candidate.head.sha === run.head_sha &&diff --git a/.github/workflows/mobile-fingerprint-label.yml b/.github/workflows/mobile-fingerprint-label.ymlindex 191c9532799..45e4c9f2ad4 100644--- a/.github/workflows/mobile-fingerprint-label.yml+++ b/.github/workflows/mobile-fingerprint-label.yml@@ -53,15 +53,18 @@ jobs:return;}- // workflow_run.pull_requests is empty for fork PRs, so resolve the- // PR from the checked commit. Requiring the PR's current head to be- // that commit keeps a slow run for an older push from overwriting a- // newer result.- const associated = await github.paginate(- github.rest.repos.listPullRequestsAssociatedWithCommit,- { owner, repo, commit_sha: run.head_sha, per_page: 100 },- );- const matching = associated.filter(+ // workflow_run.pull_requests and the commit-to-PR lookup are both+ // empty for fork PRs, so list open PRs by head owner and branch.+ // Requiring the PR's current head to be the checked commit keeps a+ // slow run for an older push from overwriting a newer result.+ const open = await github.paginate(github.rest.pulls.list, {+ owner,+ repo,+ state: "open",+ head: `${run.head_repository?.owner?.login}:${run.head_branch}`,+ per_page: 100,+ });+ const matching = open.filter((candidate) =>candidate.state === "open" &&candidate.head.sha === run.head_sha &&