Skip to content

Commit

Permalink
Paginate through all issues for close_issues workflow (nomic-ai#630)
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Guo <[email protected]>
  • Loading branch information
rguo123 authored May 18, 2023
1 parent 546600f commit 94f4018
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/close_issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const repo = context.repo;
const issues = await github.issues.listForRepo(repo);
for (let { number } of issues.data) {
let page = 1;
let issues = [];
while (true) {
const result = await github.issues.listForRepo({...repo, per_page: 100, page: page});
if (result.data.length === 0) break;
issues = issues.concat(result.data);
page += 1;
}
for (let { number } of issues) {
const issueData = await github.issues.get({...repo, issue_number: number});
const comments = await github.issues.listComments({...repo, issue_number: number});
if (issueData.data.labels.length === 0 && comments.data.length <= 1) {
if (issueData.data.labels.length === 0 && comments.data.length < 1) {
await github.issues.update({...repo, issue_number: number, state: 'closed'});
await github.issues.createComment({...repo, issue_number: number, body: 'Issue closed as it does not have any labels or comments.'});
}
Expand Down

0 comments on commit 94f4018

Please sign in to comment.