fix(steps/actions): accept callable inputs (resolve at dispatch time)

This commit is contained in:
hermes
2026-09-20 17:44:32 +00:00
parent 4705755243
commit 07ef686273
+13 -5
View File
@@ -5,7 +5,7 @@ import time
import urllib.error
import urllib.request
from dataclasses import dataclass
from typing import Any, Callable, Dict, Optional
from typing import Any, Callable, Dict, Optional, Union
from enironment import AbstractStep
from steps.git import CheckoutMerged
@@ -21,6 +21,9 @@ class GiteaActionsRun:
html_url: str
InputsSource = Union[Dict[str, str], Callable[[], Dict[str, str]], None]
class GiteaActionsTrigger(AbstractStep[GiteaActionsRun]):
"""Trigger a Gitea Actions workflow via the dispatches API."""
@@ -31,7 +34,7 @@ class GiteaActionsTrigger(AbstractStep[GiteaActionsRun]):
workflow_file: str,
ref: str,
token: str,
inputs: Optional[Dict[str, str]] = None,
inputs: InputsSource = None,
wd: Optional[CheckoutMerged] = None,
poll_timeout_sec: int = 1800,
poll_interval_sec: int = 10,
@@ -43,7 +46,7 @@ class GiteaActionsTrigger(AbstractStep[GiteaActionsRun]):
self.workflow_file = workflow_file
self.ref = ref
self.token = token
self.inputs = inputs or {}
self.inputs = inputs
self.wd = wd
self.poll_timeout_sec = poll_timeout_sec
self.poll_interval_sec = poll_interval_sec
@@ -78,9 +81,14 @@ class GiteaActionsTrigger(AbstractStep[GiteaActionsRun]):
def progress(self) -> GiteaActionsRun:
latest = self._list_recent_runs()
resolved_inputs: Dict[str, str] = {}
if callable(self.inputs):
resolved_inputs = self.inputs() or {}
elif isinstance(self.inputs, dict):
resolved_inputs = self.inputs
body: Dict[str, Any] = {"ref": self.ref}
if self.inputs:
body["inputs"] = self.inputs
if resolved_inputs:
body["inputs"] = resolved_inputs
url = (
f"{self.api_base}/repos/{self.owner}/{self.repo}"
f"/actions/workflows/{self.workflow_file}/dispatches"