Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt dispatch_publish from first events #617

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
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
20 changes: 12 additions & 8 deletions github_app_geo_project/module/dispatch_publishing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,26 @@ def get_json_schema(self) -> dict[str, Any]:
"""Get the JSON schema for the configuration."""
return {}

def get_github_application_permissions(self) -> module.GitHubApplicationPermissions:
"""Get the GitHub application permissions needed by the module."""
return module.GitHubApplicationPermissions(
permissions={"contents": "write"}, events={"repository_dispatch"}
)

def get_actions(self, context: module.GetActionContext) -> list[module.Action[None]]:
"""
Get the action related to the module and the event.

Usually the only action allowed to be done in this method is to set the pull request checks status
Note that this function is called in the web server Pod who has low resources, and this call should be fast
"""
if context.event_name == "repository_dispatch" and context.event_data.get("event_type") == "publish":
if (
context.event_name == " repository_dispatch.published"
and context.event_data.get("action") == "published"
):
return [module.Action(None)]
return []

def get_github_application_permissions(self) -> module.GitHubApplicationPermissions:
"""Get the GitHub application permissions needed by the module."""
return module.GitHubApplicationPermissions(
permissions={"contents": "write"}, events={"repository_dispatch"}
)

async def process(
self,
context: module.ProcessContext[None, None, None],
Expand All @@ -93,8 +96,9 @@ async def process(

Note that this method is called in the queue consuming Pod
"""
content = context.event_data.get("client_payload", {}).get("content", {})

for destination in CONFIG.destinations:
content = context.event_data.get("payloads", {}).get("content", {})
if destination.version_type and destination.package_type != content.get("version_type"):
continue

Expand Down
Loading