mirror of
https://github.com/espressif/openthread.git
synced 2026-09-21 08:27:33 +00:00
[ci] use head repo looking up pr_number (#13446)
The API github.rest.repos.listPullRequestsAssociatedWithCommit() can only query commits from the repo owning those commits. Although a fork PR is pushed to the base repo, the base repo doesn't have the commit yet. This commit changes the workflow to query pull request from head repo.
This commit is contained in:
@@ -65,14 +65,22 @@ jobs:
|
||||
let pr_number = context.payload.workflow_run.pull_requests?.[0]?.number
|
||||
|
||||
if (!pr_number) {
|
||||
const head_repo = context.payload.workflow_run.head_repository?.full_name;
|
||||
if (!head_repo) {
|
||||
core.setFailed('Head repository not found in workflow run context payload.');
|
||||
return;
|
||||
}
|
||||
const [owner, repo] = head_repo.split('/')
|
||||
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
owner,
|
||||
repo,
|
||||
commit_sha: context.payload.workflow_run.head_sha,
|
||||
})
|
||||
const open_pr = prs?.find(pr => pr.state === 'open') || prs?.[0]
|
||||
if (open_pr) {
|
||||
pr_number = open_pr.number
|
||||
const base_full_name = `${context.repo.owner}/${context.repo.repo}`
|
||||
const pr = prs?.find(pr => pr.base.repo.full_name === base_full_name && pr.state === 'open') ||
|
||||
prs?.find(pr => pr.base.repo.full_name === base_full_name);
|
||||
if (pr) {
|
||||
pr_number = pr.number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user