Skip to main content

Case Study 8: GitHub Repository Housekeeping Bot (Challenge)

:::info Challenge — no solution provided This is an open challenge, in the same style as Case Study 7. Design your own solution and use the suggested libraries as a starting point rather than a strict requirement. :::

Scenario​

An engineering organization maintains over two hundred repositories. Stale branches and abandoned pull requests accumulate over time and are rarely cleaned up manually. Your task is to build a script that audits repositories across the organization and reports housekeeping issues.

Suggested Libraries​

  • requests
  • datetime

Sample Files You May Create​

  • org_repo_list — a cached list of repositories
  • housekeeping_report — the output report

Requirements​

  • Retrieve the list of repositories for an organization.
  • Handle paginated API responses.
  • Respect API rate limits with backoff.
  • Identify branches with no recent commit activity.
  • Identify pull requests with no recent updates.
  • Exclude protected branches such as main or develop from cleanup checks.
  • Produce a summary report per repository.

Things to think about​

  • The GitHub API paginates results via a Link header rather than a page-number parameter — how would your paginator know when to stop?
  • What should happen when you hit a rate limit halfway through auditing 200 repositories? Should the whole run fail, or should it back off and resume?