Skip to content

Commit 472673c

Browse files
authored
feat(issue triage): Get all labels of the repository (#346)
Use a loop on the paginated API to collect all the labels of the repo, as the current implementation only get 30 of them. I did not modified the current workflows you are using [here](https://github.com/google-github-actions/run-gemini-cli/blob/main/.github/workflows/gemini-triage.yml), but if it makes sense for you I can update the PR. We might think about an additional option to use specific patterns to select only some labels lately? Thanks in advance for the review --------- Signed-off-by: Nicolas Schweitzer <nicolas.schweitzer@datadoghq.com>
1 parent 0f1a5b3 commit 472673c

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

.github/workflows/gemini-scheduled-triage.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,14 @@ jobs:
4646
# GITHUB_TOKEN provided by the action has enough permissions to read
4747
# the labels.
4848
script: |-
49-
const { data: labels } = await github.rest.issues.listLabelsForRepo({
49+
const labels = [];
50+
for await (const response of github.paginate.iterator(github.rest.issues.listLabelsForRepo, {
5051
owner: context.repo.owner,
5152
repo: context.repo.repo,
52-
});
53+
per_page: 100, // Maximum per page to reduce API calls
54+
})) {
55+
labels.push(...response.data);
56+
}
5357
5458
if (!labels || labels.length === 0) {
5559
core.setFailed('There are no issue labels in this repository.')

.github/workflows/gemini-triage.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ jobs:
3737
# GITHUB_TOKEN provided by the action has enough permissions to read
3838
# the labels.
3939
script: |-
40-
const { data: labels } = await github.rest.issues.listLabelsForRepo({
40+
const labels = [];
41+
for await (const response of github.paginate.iterator(github.rest.issues.listLabelsForRepo, {
4142
owner: context.repo.owner,
4243
repo: context.repo.repo,
43-
});
44+
per_page: 100, // Maximum per page to reduce API calls
45+
})) {
46+
labels.push(...response.data);
47+
}
4448
4549
if (!labels || labels.length === 0) {
4650
core.setFailed('There are no issue labels in this repository.')

examples/workflows/issue-triage/gemini-scheduled-triage.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,14 @@ jobs:
4646
# GITHUB_TOKEN provided by the action has enough permissions to read
4747
# the labels.
4848
script: |-
49-
const { data: labels } = await github.rest.issues.listLabelsForRepo({
49+
const labels = [];
50+
for await (const response of github.paginate.iterator(github.rest.issues.listLabelsForRepo, {
5051
owner: context.repo.owner,
5152
repo: context.repo.repo,
52-
});
53+
per_page: 100, // Maximum per page to reduce API calls
54+
})) {
55+
labels.push(...response.data);
56+
}
5357
5458
if (!labels || labels.length === 0) {
5559
core.setFailed('There are no issue labels in this repository.')

examples/workflows/issue-triage/gemini-triage.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ jobs:
3737
# GITHUB_TOKEN provided by the action has enough permissions to read
3838
# the labels.
3939
script: |-
40-
const { data: labels } = await github.rest.issues.listLabelsForRepo({
40+
const labels = [];
41+
for await (const response of github.paginate.iterator(github.rest.issues.listLabelsForRepo, {
4142
owner: context.repo.owner,
4243
repo: context.repo.repo,
43-
});
44+
per_page: 100, // Maximum per page to reduce API calls
45+
})) {
46+
labels.push(...response.data);
47+
}
4448
4549
if (!labels || labels.length === 0) {
4650
core.setFailed('There are no issue labels in this repository.')

0 commit comments

Comments
 (0)