Skip to content

Commit

Permalink
Added paginated call for getRepos (#25)
Browse files Browse the repository at this point in the history
* Added pagination for getRepos

* linter warnings fixed for get-repos file

* npm version patch

* npm version reset

* 1.0.1

---------

Co-authored-by: Salvador real <[email protected]>
  • Loading branch information
davinc and srealmoreno authored Feb 2, 2023
1 parent adfa793 commit 61653e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dist/label-sync-action.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "label-sync-action",
"version": "1.0.0",
"version": "1.0.1",
"engines": {
"node": "v16",
"npm": "v8"
Expand Down
7 changes: 2 additions & 5 deletions src/services/get-repos.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { AutoDiscoverReposOptions } from '@interfaces/inputs'
import { components } from '@octokit/openapi-types'
import { isArrayNotEmpty, isArrayOfStrings, isRegExp, isString } from '@utils/index.js'
import log from '@utils/log.js'
import { Octokit } from 'octokit'
import regexParser from 'regex-parser'

type repository = components['schemas']['repository']

export async function getRepos (token: string, autoDiscoverRepos: AutoDiscoverReposOptions): Promise<string[]> {
const {
owner,
Expand All @@ -22,8 +19,8 @@ export async function getRepos (token: string, autoDiscoverRepos: AutoDiscoverRe
auth: token
})

const { data }: { data: repository[] } = await octokit
.request(`GET /${accountType}s/{${accountType}}/repos`, { [accountType]: owner })
const data = await octokit
.paginate(octokit.rest.repos.listForAuthenticatedUser, { owner, per_page: 100 })
.catch((error: Error) => {
throw new Error(
`Failed to fetch repos from owner: '${owner}' accountType: '${accountType}' GitHub API error: ${error.message}`
Expand Down

0 comments on commit 61653e5

Please sign in to comment.