Skip to content

Commit 3415bd5

Browse files
authored
Fix previews for post-build events (microsoft#3103)
1 parent e1b2f7f commit 3415bd5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

.github/workflows/deploy-preview.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ jobs:
5858
pull_number: pr.number,
5959
})).data;
6060
} else {
61-
console.log("PR not found in workflow run");
61+
const q = `is:pr is:open repo:${context.repo.owner}/${context.repo.repo} sha:${workflowRun.head_sha}`;
62+
console.log(`PR not found in workflow run, searching for it with ${q}`);
6263
// PRs sent from forks do not get the pull_requests field set.
6364
// https://github.com/orgs/community/discussions/25220
64-
pr = (await github.rest.pulls.list({
65-
owner: context.repo.owner,
66-
repo: context.repo.repo,
67-
head: workflowRun.head_sha,
68-
per_page: 1,
69-
})).data[0];
65+
const response = await github.rest.search.issuesAndPullRequests({ q });
66+
if (response.data.items.length > 0) {
67+
pr = response.data.items[0];
68+
}
7069
}
7170
}
7271

0 commit comments

Comments
 (0)