Skip to content

Commit b2b07e2

Browse files
committed
Iterate over results until we don't get a nextPageToken
1 parent 46a5711 commit b2b07e2

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ runs:
6363
-e GITHUB_INSTALLATION_ID="$GITHUB_INSTALLATION_ID" \
6464
-e GITHUB_PRIVATE_KEY="$GITHUB_PRIVATE_KEY" \
6565
-e IGNORED_USERS="$IGNORED_USERS" \
66-
docker.pkg.github.com/appvia/githubusermanager/githubusermanager:v1.0.5
66+
docker.pkg.github.com/remarkable/githubusermanager/githubusermanager:v1.0.6
6767
shell: bash
6868
env:
6969
GOOGLE_EMAIL_ADDRESS: ${{ inputs.google-email-address }}

src/google.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,21 @@ export async function getAdminService() {
2626

2727
export async function getGithubUsersFromGoogle(): Promise<Set<string>> {
2828
const service = await mod.getAdminService()
29+
let githubAccounts = new Set<string>()
30+
let pageToken = null
2931

30-
const userList = await service.users.list({
31-
customer: 'my_customer',
32-
maxResults: 250,
33-
projection: 'custom',
34-
fields: 'users(customSchemas/Accounts/github(value))',
35-
customFieldMask: 'Accounts',
36-
})
37-
38-
const githubAccounts = mod.formatUserList(userList.data.users)
32+
do {
33+
const userList = await service.users.list({
34+
customer: 'my_customer',
35+
maxResults: 250,
36+
projection: 'custom',
37+
pageToken: pageToken,
38+
fields: 'users(customSchemas/Accounts/github(value)),pageToken',
39+
customFieldMask: 'Accounts',
40+
})
41+
pageToken = userList.data.nextPageToken
42+
githubAccounts = new Set([...githubAccounts, ...formatUserList(userList.data.users)])
43+
} while (pageToken != null)
3944
return githubAccounts
4045
}
4146

0 commit comments

Comments
 (0)