diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29a7fdd..90ba18f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,19 +14,19 @@ repos: stages: [commit] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort stages: [commit] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black stages: [commit] - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 + rev: v4.0.0-alpha.8 hooks: - id: prettier types_or: [javascript, jsx, ts, tsx, markdown, yaml, json] diff --git a/nonebot/adapters/github/adapter.py b/nonebot/adapters/github/adapter.py index 0da6931..5f3603d 100644 --- a/nonebot/adapters/github/adapter.py +++ b/nonebot/adapters/github/adapter.py @@ -126,23 +126,23 @@ def payload_to_event( types = events.get(event_name) if isinstance(types, dict): if action := event_payload.get("action"): - return types[action].parse_obj({ - "id": event_id, "name": event_name, "payload": event_payload - }) + return types[action].parse_obj( + {"id": event_id, "name": event_name, "payload": event_payload} + ) else: raise ValueError( f"Payload missing action, either of {', '.join(types)}." ) elif types is None: raise ValueError(f"Unknown event type {event_name}.") - return types.parse_obj({ - "id": event_id, "name": event_name, "payload": event_payload - }) + return types.parse_obj( + {"id": event_id, "name": event_name, "payload": event_payload} + ) except Exception as e: log("WARNING", f"Failed to parse webhook payload {event_id}", e) - return Event.parse_obj({ - "id": event_id, "name": event_name, "payload": event_payload - }) + return Event.parse_obj( + {"id": event_id, "name": event_name, "payload": event_payload} + ) @classmethod def custom_send( diff --git a/nonebot/adapters/github/event.py b/nonebot/adapters/github/event.py index 79635cd..53b55e8 100644 --- a/nonebot/adapters/github/event.py +++ b/nonebot/adapters/github/event.py @@ -260,6 +260,12 @@ from githubkit.webhooks.models import ( DependabotAlertDismissed as DependabotAlertDismissedPayload, ) +from githubkit.webhooks.models import ( + DeploymentReviewApproved as DeploymentReviewApprovedPayload, +) +from githubkit.webhooks.models import ( + DeploymentReviewRejected as DeploymentReviewRejectedPayload, +) from githubkit.webhooks.models import ( DiscussionCommentCreated as DiscussionCommentCreatedPayload, ) @@ -272,6 +278,9 @@ from githubkit.webhooks.models import ( CodeScanningAlertReopened as CodeScanningAlertReopenedPayload, ) +from githubkit.webhooks.models import ( + DeploymentReviewRequested as DeploymentReviewRequestedPayload, +) from githubkit.webhooks.models import ( DiscussionCategoryChanged as DiscussionCategoryChangedPayload, ) @@ -656,6 +665,18 @@ class DeploymentProtectionRuleRequested(Event): payload: DeploymentProtectionRuleRequestedPayload +class DeploymentReviewApproved(Event): + payload: DeploymentReviewApprovedPayload + + +class DeploymentReviewRejected(Event): + payload: DeploymentReviewRejectedPayload + + +class DeploymentReviewRequested(Event): + payload: DeploymentReviewRequestedPayload + + class DeploymentStatusCreated(Event): payload: DeploymentStatusCreatedPayload @@ -1494,6 +1515,11 @@ class WorkflowRunRequested(Event): "deployment_protection_rule": { "requested": DeploymentProtectionRuleRequested, }, + "deployment_review": { + "approved": DeploymentReviewApproved, + "rejected": DeploymentReviewRejected, + "requested": DeploymentReviewRequested, + }, "deployment_status": { "created": DeploymentStatusCreated, },