From 44486f66336198c78f26810e5aeb6925ed9d873f Mon Sep 17 00:00:00 2001 From: phaer Date: Thu, 26 Oct 2023 11:08:07 +0200 Subject: [PATCH] skip github projects without sufficient perms --- buildbot_nix/github_projects.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/buildbot_nix/github_projects.py b/buildbot_nix/github_projects.py index fb8f4b0..6dfa335 100644 --- a/buildbot_nix/github_projects.py +++ b/buildbot_nix/github_projects.py @@ -133,10 +133,18 @@ def create_project_hook( def refresh_projects(github_token: str, repo_cache_file: Path) -> None: - repos = paginated_github_request( - "https://api.github.com/user/repos?per_page=100", - github_token, - ) + repos = [] + + for repo in paginated_github_request( + "https://api.github.com/user/repos?per_page=100", + github_token, + ): + if not repo["permissions"]["admin"]: + name = repo['full_name'] + log.msg(f"skipping {name} because we do not have admin privileges, needed for hook management") + else: + repos.append(repo) + with NamedTemporaryFile("w", delete=False, dir=repo_cache_file.parent) as f: try: f.write(json.dumps(repos))