Skip to content

Commit

Permalink
fix(pingcap/community): fix sync owners deno script (#2382)
Browse files Browse the repository at this point in the history
Fixes #2377
Ref octokit/oauth-app.js#424

Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo authored Aug 25, 2023
1 parent 8ee681c commit 9c24aa0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions scripts/pingcap/community/update-prow-owners.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as yaml from "https://deno.land/[email protected]/yaml/mod.ts";
import * as flags from "https://deno.land/[email protected]/flags/mod.ts";
import { dirname } from "https://deno.land/[email protected]/path/mod.ts";
import { Octokit } from "https://esm.sh/octokit@2.0.19";
import { Octokit } from "npm:/octokit@3.1.0";

const HEAD_REF = `bot/update-owners-${Date.now()}`;
const COMMIT_MESSAGE = "[skip ci] Update OWNERS file\n\n\nskip-checks: true";
Expand Down Expand Up @@ -485,21 +485,18 @@ async function main(
const pullRequests: { owner: string; repo: string; num: number }[] = [];
// Create or update the `OWNERS` files in each repository.
await Promise.all(
Array.from(owners).map(async ([repository, ownersMap], index) => {
Array.from(owners).filter(([repository]) => {
return !(
// skip for repo in other ORG.
repository.includes("/") ||
// skip if not same with the only repo name.
(only_repo && only_repo.repo !== repository)
);
}).map(async ([repository, ownersMap], index) => {
// Introduce a delay between API requests to avoid rate limit errors
const delay = 5000 * index; // Adjust the delay time according to your needs
await new Promise((resolve) => setTimeout(resolve, delay));

// skip for repo in other ORG.
if (repository.includes("/")) {
return;
}

// skip if not same with the only repo name.
if (only_repo && only_repo.repo !== repository) {
return;
}

console.debug(`🫧 prepare update for repo: ${owner}/${repository}`);
// get the base ref for create PR.
const baseRef = await (async () => {
Expand Down

0 comments on commit 9c24aa0

Please sign in to comment.