skip github projects without sufficient perms

This commit is contained in:
phaer 2023-10-26 11:08:07 +02:00 committed by Mic92
parent a758cb41ca
commit 44486f6633

View file

@ -133,10 +133,18 @@ def create_project_hook(
def refresh_projects(github_token: str, repo_cache_file: Path) -> None: def refresh_projects(github_token: str, repo_cache_file: Path) -> None:
repos = paginated_github_request( repos = []
"https://api.github.com/user/repos?per_page=100",
github_token, 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: with NamedTemporaryFile("w", delete=False, dir=repo_cache_file.parent) as f:
try: try:
f.write(json.dumps(repos)) f.write(json.dumps(repos))