()
| 236 | |
| 237 | |
| 238 | def main() -> None: |
| 239 | logging.basicConfig(level=logging.INFO) |
| 240 | settings = Settings() # ty: ignore[missing-argument] |
| 241 | logging.info(f"Using config: {settings.model_dump_json()}") |
| 242 | g = Github(settings.github_token.get_secret_value()) |
| 243 | repo = g.get_repo(settings.github_repository) |
| 244 | |
| 245 | pr_nodes = get_pr_nodes(settings=settings) |
| 246 | contributors_results = get_contributors(pr_nodes=pr_nodes) |
| 247 | authors = contributors_results.authors |
| 248 | |
| 249 | top_contributors = get_users_to_write( |
| 250 | counter=contributors_results.contributors, |
| 251 | authors=authors, |
| 252 | ) |
| 253 | |
| 254 | top_translators = get_users_to_write( |
| 255 | counter=contributors_results.translators, |
| 256 | authors=authors, |
| 257 | ) |
| 258 | top_translations_reviewers = get_users_to_write( |
| 259 | counter=contributors_results.translation_reviewers, |
| 260 | authors=authors, |
| 261 | ) |
| 262 | |
| 263 | # For local development |
| 264 | # contributors_path = Path("../docs/en/data/contributors.yml") |
| 265 | contributors_path = Path("./docs/en/data/contributors.yml") |
| 266 | # translators_path = Path("../docs/en/data/translators.yml") |
| 267 | translators_path = Path("./docs/en/data/translators.yml") |
| 268 | # translation_reviewers_path = Path("../docs/en/data/translation_reviewers.yml") |
| 269 | translation_reviewers_path = Path("./docs/en/data/translation_reviewers.yml") |
| 270 | |
| 271 | updated = [ |
| 272 | update_content(content_path=contributors_path, new_content=top_contributors), |
| 273 | update_content(content_path=translators_path, new_content=top_translators), |
| 274 | update_content( |
| 275 | content_path=translation_reviewers_path, |
| 276 | new_content=top_translations_reviewers, |
| 277 | ), |
| 278 | ] |
| 279 | |
| 280 | if not any(updated): |
| 281 | logging.info("The data hasn't changed, finishing.") |
| 282 | return |
| 283 | |
| 284 | logging.info("Setting up GitHub Actions git user") |
| 285 | subprocess.run(["git", "config", "user.name", "github-actions[bot]"], check=True) |
| 286 | subprocess.run( |
| 287 | ["git", "config", "user.email", "github-actions[bot]@users.noreply.github.com"], |
| 288 | check=True, |
| 289 | ) |
| 290 | branch_name = f"fastapi-people-contributors-{secrets.token_hex(4)}" |
| 291 | logging.info(f"Creating a new branch {branch_name}") |
| 292 | subprocess.run(["git", "checkout", "-b", branch_name], check=True) |
| 293 | logging.info("Adding updated file") |
| 294 | subprocess.run( |
| 295 | [ |
no test coverage detected
searching dependent graphs…