Skip to content

Commit

Permalink
Merge pull request #617 from camptocamp/fix-dispatch
Browse files Browse the repository at this point in the history
Adapt dispatch_publish from first events
  • Loading branch information
sbrunner authored Nov 19, 2024
2 parents c88009f + 89e1909 commit f7bbda1
Showing 1 changed file with 12 additions and 8 deletions.
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

0 comments on commit f7bbda1

Please sign in to comment.