Retrieve every page of repo runner labels

This commit is contained in:
Chris Sidi
2023-01-25 22:08:52 -05:00
parent 1165833508
commit f02dc86728
@@ -33,16 +33,20 @@ export async function getRunnerLabels(client: Octokit, cache: TTLCache, owner: s
async function fetchRunnerLabels(client: Octokit, owner: string, name: string): Promise<Set<string>> {
const labels = new Set<string>();
try {
const response = await client.actions.listSelfHostedRunnersForRepo({
owner,
repo: name
});
const itor = client.paginate.iterator(client.actions.listSelfHostedRunnersForRepo,
{
owner,
repo: name,
per_page: 100
});
for (const runner of response.data.runners) {
for (const label of runner.labels) {
labels.add(label.name);
for await (const response of itor) {
for (const runner of response.data) {
for (const label of runner.labels) {
labels.add(label.name);
}
}
}
}
} catch (e) {
console.log("Failure to retrieve runner labels: ", e);
}