Skip to content

Commit de9f8ab

Browse files
authored
Repo Gardening: Add labels in batches of 30 (#53883)
1 parent 632c441 commit de9f8ab

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Labels: Add in batches of 30 to prevent timeouts.

‎projects/github-actions/repo-gardening/src/tasks/add-labels/index.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,16 @@ async function addLabels( payload: PullRequestEvent, octokit: OctokitClient ): P
360360

361361
debug( `add-labels: Adding labels ${ labelsToAdd } to PR #${ number }` );
362362

363-
await octokit.rest.issues.addLabels( {
364-
owner: owner.login,
365-
repo: name,
366-
issue_number: number,
367-
labels: labelsToAdd,
368-
} );
363+
// Large requests sometimes fail (perhaps a timeout), so add labels in batches.
364+
const batchSize = 30;
365+
for ( let i = 0; i < labelsToAdd.length; i += batchSize ) {
366+
await octokit.rest.issues.addLabels( {
367+
owner: owner.login,
368+
repo: name,
369+
issue_number: number,
370+
labels: labelsToAdd.slice( i, i + batchSize ),
371+
} );
372+
}
369373
}
370374

371375
export default addLabels;

0 commit comments

Comments
 (0)