diff --git a/scripts/ci/pr-bot/processNewPrs.ts b/scripts/ci/pr-bot/processNewPrs.ts index 776ae8aa83a9..dd20d4a98c2b 100644 --- a/scripts/ci/pr-bot/processNewPrs.ts +++ b/scripts/ci/pr-bot/processNewPrs.ts @@ -182,6 +182,26 @@ async function processPull( reviewerConfig: typeof ReviewerConfig, stateClient: typeof PersistentState ) { + if (pull.user.login === "dependabot[bot]") { + const files = await github.getPrFiles(pull.number); + const touchesContainer = files.some((file: string) => + file.startsWith("sdks/python/container/") + ); + if (touchesContainer) { + console.log( + `Closing PR ${pull.number} because it is a dependabot PR touching container/` + ); + await github.addPrComment( + pull.number, + "Closing this PR because dependabot updates for container/** are not allowed due to generated files " + + "and excluded_paths is disabled due to dependabot/dependabot-core#14408. " + + "Once issue is resolved, please remove this step." + ); + await github.closePr(pull.number); + return; + } + } + let prState = await stateClient.getPrState(pull.number); if (!needsProcessed(pull, prState)) { return; diff --git a/scripts/ci/pr-bot/shared/githubUtils.ts b/scripts/ci/pr-bot/shared/githubUtils.ts index 667255b16924..0d287bd09379 100644 --- a/scripts/ci/pr-bot/shared/githubUtils.ts +++ b/scripts/ci/pr-bot/shared/githubUtils.ts @@ -70,6 +70,27 @@ export async function nextActionAuthor( }); } +export async function closePr(pullNumber: number) { + await getGitHubClient().rest.pulls.update({ + owner: REPO_OWNER, + repo: REPO, + pull_number: pullNumber, + state: "closed", + }); +} + +export async function getPrFiles(pullNumber: number): Promise { + const files = await getGitHubClient().paginate( + getGitHubClient().rest.pulls.listFiles, + { + owner: REPO_OWNER, + repo: REPO, + pull_number: pullNumber, + } + ); + return files.map((file: any) => file.filename); +} + export async function checkIfCommitter(username: string): Promise { const permissionLevel = ( await getGitHubClient().rest.repos.getCollaboratorPermissionLevel({