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: https://my.github.server/pulls?q=is:open is:pr org:my-org-name
.
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.
The document also has /repos
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 octokit.request( 'GET /pulls?q=...' )
as above, I get a 404.
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?
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.