Skip to content
Open
Changes from 1 commit
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
13 changes: 9 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 @@ -60,6 +61,7 @@ class RepoUpdateResult:
git_stderr: str = ""
docker_stdout: str = ""
docker_stderr: str = ""
maybe_rollback_result: Optional[bool] = None


def load_config(development: bool):
Expand All @@ -69,7 +71,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 +207,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