Skip to content

Commit 0a0531a

Browse files
committed
Improve listing runs on huge repos
1 parent 2995937 commit 0a0531a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

action.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ exports.action = async function action() {
8989
}
9090
};
9191

92+
async function getPull({ org, repoName, pullNumber }) {
93+
return (
94+
await octokit.rest.pulls.get({
95+
owner: org,
96+
repo: repoName,
97+
pull_number: pullNumber,
98+
})
99+
).data;
100+
}
101+
92102
async function actionIssue() {
93103
console.info(`Calling action on issue`);
94104
const { owner, repo, issueNumber, comment } = await getActionParameters();
@@ -98,9 +108,18 @@ async function actionIssue() {
98108
return;
99109
}
100110

111+
const pull = await getPull({
112+
org: owner,
113+
repoName: repo,
114+
pullNumber: issueNumber,
115+
});
116+
const {
117+
head: { ref: headRef },
118+
} = pull;
119+
101120
const workflowRuns = await octokit.paginate(
102121
"GET /repos/{owner}/{repo}/actions/runs",
103-
{ owner, repo, issue_number: issueNumber }
122+
{ owner, repo, branch: headRef }
104123
);
105124
const reviewWorkflows = workflowRuns.filter(
106125
({ name, event, pull_requests: pullRequests }) =>

0 commit comments

Comments
 (0)