mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-23 10:55:45 -04:00
65da31647c
- Deleted obsolete trigger files for various GitHub events including commit comments, create, delete, deployment, discussion, and others to streamline the trigger set. - Introduced a new `issues.py` trigger to handle GitHub issue events, enhancing event handling capabilities. - Added corresponding `issues.yaml` configuration to define the new trigger's properties and behavior. These changes improve the overall functionality and maintainability of the GitHub trigger integration, ensuring a more efficient event handling process.
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from werkzeug import Request
|
|
|
|
from dify_plugin.entities.trigger import Event
|
|
from dify_plugin.errors.trigger import TriggerIgnoreEventError
|
|
from dify_plugin.interfaces.trigger import TriggerEvent
|
|
|
|
|
|
class IssuesTrigger(TriggerEvent):
|
|
"""
|
|
GitHub Issue Event Trigger
|
|
|
|
This unified trigger handles all GitHub issue events and extracts relevant
|
|
information from the webhook payload to provide as variables to the workflow.
|
|
"""
|
|
|
|
def _trigger(self, request: Request, parameters: Mapping[str, Any]) -> Event:
|
|
"""
|
|
Handle GitHub issue event trigger with comprehensive filtering
|
|
|
|
Parameters:
|
|
- event: Select which issue actions to trigger on (opened, closed, reopened, edited, assigned, labeled, etc.)
|
|
- labels: Only trigger if issue has these labels (comma-separated)
|
|
- exclude_labels: Don't trigger if issue has these labels (comma-separated)
|
|
- assignee: Only trigger if assigned to these users (comma-separated)
|
|
- authors: Only trigger for issues from these authors (comma-separated)
|
|
- exclude_authors: Don't trigger for issues from these authors (comma-separated)
|
|
- milestone: Only trigger for issues with these milestones (comma-separated)
|
|
- title_pattern: Only trigger if title matches this pattern (supports wildcards, comma-separated)
|
|
- body_contains: Only trigger if body contains these keywords (comma-separated)
|
|
"""
|
|
# Get the event payload
|
|
payload = request.get_json()
|
|
if not payload:
|
|
raise ValueError("No payload received")
|
|
|
|
# Get the action type
|
|
action = payload.get("action", "")
|
|
|
|
# Apply event filter
|
|
event = parameters.get("event", [])
|
|
if event and action not in event:
|
|
raise TriggerIgnoreEventError(f"Action '{action}' not in filter list: {event}")
|
|
|
|
return Event(
|
|
variables={
|
|
"action": action,
|
|
}
|
|
)
|