in packages/repocop/src/remediation/dependency_graph-integrator/send-to-sns.ts [183:240]
export async function sendReposToDependencyGraphIntegrator(
config: Config,
repoLanguages: github_languages[],
productionRepos: Repository[],
productionWorkflowUsages: guardian_github_actions_usage[],
repoCustomProperties: github_repository_custom_properties[],
repoOwners: view_repo_ownership[],
repoCount: number,
octokit: Octokit,
): Promise<void> {
const reposRequiringDepGraphIntegration: RepositoryWithDepGraphLanguage[] =
getSuitableReposWithoutWorkflows(
repoLanguages,
productionRepos,
productionWorkflowUsages,
repoCustomProperties,
);
if (reposRequiringDepGraphIntegration.length !== 0) {
console.log(
`Found ${reposRequiringDepGraphIntegration.length} repos requiring dependency graph integration`,
);
const shuffledRepos = shuffle(reposRequiringDepGraphIntegration);
const selectedRepos: RepositoryWithDepGraphLanguage[] = [];
while (selectedRepos.length < repoCount && shuffledRepos.length > 0) {
const repo = shuffledRepos.pop();
if (repo) {
console.log('Checking for existing PR for', repo.name);
const existingPr = await getExistingPullRequest(
octokit,
repo.name,
'guardian',
'gu-dependency-graph-integrator[bot]',
);
console.log(
existingPr
? `Existing PR found for ${repo.name}`
: `PR not found for ${repo.name}`,
);
if (!existingPr) {
selectedRepos.push(repo);
}
}
}
const eventsToSend: DependencyGraphIntegratorEvent[] =
createSnsEventsForDependencyGraphIntegration(selectedRepos, repoOwners);
for (const event of eventsToSend) {
await sendOneRepoToDepGraphIntegrator(config, event);
}
} else {
console.log('No suitable repos found to create events for.');
}
}