How do I list open PRs across all repositories in my organization using octokit?
P粉966335669
2023-09-01 19:54:24
<p>I want to write a script in Javascript to query all open github PRs in all repositories in my organization. I can do this in the browser using this URL: <code>https://my.github.server/pulls?q=is:open is:pr org:my-org-name</code>. </p>
<p>But using octokit, I need to provide the name of the repository to search. It looks like the github API requires it as well, but as I said, the URL above doesn't provide the repository name, but it works just fine. </p>
<p>The document also has <code>/repos</code> at the beginning, but mine doesn't have it above. I can't find the one I'm using in the github API documentation. If I try <code>octokit.request( 'GET /pulls?q=...' )</code> as above, I get a 404. </p>
<p>I'm sure there is a way to list the repositories and run the above search on each one, but I have dozens of repositories so this will probably be much slower. Is there any way to do it in one request? </p>
It does support filtering by organization. use:
There is no direct way to use GitHub's API or Octokit to get all open PRs in all repositories within an organization in a single request. The Search API can search for PRs, but does not support filtering by organization.
You can get a list of all repositories in your organization and get all pull requests for each repository using the repository list.
Example:
Not sure how slow this would be in your case. Anyway, I hope this helps.