Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import subprocess
import threading
from typing import Optional

from dotenv import load_dotenv
import uvicorn
Expand Down Expand Up @@ -69,7 +70,8 @@ def load_config(development: bool):
with open("config.yml") as f:
loaded_yaml = yaml.safe_load(f)
for config in loaded_yaml.get("repos", []):
parsed = RepoToWatch(**config)
allowed = {k: v for k, v in config.items() if k in RepoToWatch.__dataclass_fields__}
parsed = RepoToWatch(**allowed)
result[(parsed.name, parsed.branch)] = parsed

return result
Expand Down Expand Up @@ -204,9 +206,11 @@ async def github_webhook(request: Request):

logger.info(f"Push to {branch} detected for {repo_name}")
# update the repo
thread = threading.Thread(target=update_repo, args=(config[key],))
thread.start()

if args.development:
update_repo(config[key], commit)
else:
thread = threading.Thread(target=update_repo, args=(config[key], commit))
thread.start()
return {"status": "webhook received"}


Expand Down