Fix webhook after refactoring
This commit is contained in:
parent
b7c68285f0
commit
83fb48d982
1 changed files with 14 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
from fastapi import APIRouter, BackgroundTasks, Header, Request
|
from fastapi import APIRouter, BackgroundTasks, Header, Request
|
||||||
|
|
||||||
from .controller import controller
|
from .controller import controller
|
||||||
|
from .github import CommitInfo
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
@ -13,24 +14,24 @@ async def receive_payload(
|
||||||
) -> None:
|
) -> None:
|
||||||
# TODO check x-hub-signature
|
# TODO check x-hub-signature
|
||||||
payload = await request.json()
|
payload = await request.json()
|
||||||
repo = payload.get("repository").get("full_name")
|
|
||||||
if not repo:
|
|
||||||
return
|
|
||||||
action = payload.get("action")
|
|
||||||
if x_github_event == "pull_request":
|
if x_github_event == "pull_request":
|
||||||
if action in ("opened", "synchronize"):
|
if payload["action"] in ("opened", "synchronize"):
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
controller.deploy_or_start,
|
controller.deploy_or_start,
|
||||||
repo=repo,
|
CommitInfo(
|
||||||
|
repo=payload["repository"]["full_name"],
|
||||||
target_branch=payload["pull_request"]["base"]["ref"],
|
target_branch=payload["pull_request"]["base"]["ref"],
|
||||||
pr=payload["pull_request"]["number"],
|
pr=payload["pull_request"]["number"],
|
||||||
git_commit=payload["pull_request"]["head"]["sha"],
|
git_commit=payload["pull_request"]["head"]["sha"],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
elif x_github_event == "push":
|
elif x_github_event == "push":
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
controller.deploy_or_start,
|
controller.deploy_or_start,
|
||||||
repo=repo,
|
CommitInfo(
|
||||||
|
repo=payload["repository"]["full_name"],
|
||||||
target_branch=payload["ref"].split("/")[-1],
|
target_branch=payload["ref"].split("/")[-1],
|
||||||
pr=None,
|
pr=None,
|
||||||
git_commit=payload["after"],
|
git_commit=payload["after"],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue