Skip to content

Commit

Permalink
fix: consider optional data received via GitHub webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Feb 6, 2024
1 parent f830607 commit 77f60c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion otterdog/webapp/webhook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ async def on_issue_comment_received(data):
if event.installation is None or event.organization is None:
return success()

# currently we only handle comments to pull requests
if event.issue.pull_request is None:
return success()

otterdog_config = get_otterdog_config()

if event.repository.name != otterdog_config.default_config_repo:
return success()

if event.action in ["created", "edited"] and "/pull/" in event.issue.html_url:
if event.action in ["created", "edited"]:
org_id = event.organization.login
installation_id = event.installation.id

Expand Down
12 changes: 10 additions & 2 deletions otterdog/webapp/webhook/github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,23 @@ class Comment(BaseModel):
updated_at: str


class AssociatedPullRequest(BaseModel):
"""Indicates the associated pull request for an issue comment."""

url: str
html_url: str


class Issue(BaseModel):
"""Represents an issue"""

number: int
node_id: str
title: str
state: str
draft: bool
body: Optional[str]
draft: Optional[bool] = None
body: Optional[str] = None
pull_request: Optional[AssociatedPullRequest] = None
html_url: str


Expand Down

0 comments on commit 77f60c2

Please sign in to comment.