@@ -16,6 +16,31 @@ class WorkflowDescriptor:
1616 label : str
1717
1818
19+ def get_input_compat (name : str , * , required : bool = False ) -> str :
20+ """Reads action inputs while tolerating runner normalization.
21+
22+ Unit tests for these actions frequently monkeypatch `core.get_input`.
23+ We prefer `core.get_input` first, then fall back to direct env lookups
24+ that accept both hyphen and underscore variants.
25+ """
26+
27+ value = core .get_input (name , required = False )
28+ if value :
29+ return value .strip ()
30+
31+ normalized = name .replace (" " , "_" ).upper ()
32+ candidates = {normalized , normalized .replace ("-" , "_" ), normalized .replace ("_" , "-" )}
33+ for candidate in candidates :
34+ env_value = os .getenv (f"INPUT_{ candidate } " , "" )
35+ if env_value :
36+ return env_value .strip ()
37+
38+ if required :
39+ # Preserve the same error message format as actions_toolkit.
40+ return core .get_input (name , required = True )
41+ return ""
42+
43+
1944def get_github_api_base_url () -> str :
2045 raw = (os .environ .get ("GITHUB_API_URL" ) or "https://api.github.com" ).strip ()
2146 parsed = urlparse (raw )
@@ -114,17 +139,17 @@ def find_artifact_download_url(
114139
115140def run () -> None :
116141 try :
117- token = core . get_input ("github-token" , required = True )
118- sha = core . get_input ("sha" , required = True ).strip ()
119- trigger_event = core . get_input ("trigger-event" )
120- head_branch = core . get_input ("head-branch" )
121- is_fork = (core . get_input ("is-fork" ) or "false" ).strip ().lower () == "true"
122- skip_hotfix = (core . get_input ("skip-hotfix" ) or "false" ).strip ().lower () == "true"
123- skip_forks = (core . get_input ("skip-forks" ) or "false" ).strip ().lower () == "true"
124- require_trigger_event = (core . get_input ("require-trigger-event" ) or "" ).strip ()
125- build_workflow_file = core . get_input ("build-workflow-file" , required = True ).strip ()
126- artifact_name = core . get_input ("artifact-name" , required = True ).strip ()
127- required_workflows = parse_required_workflows (core . get_input ("required-workflows-json" , required = True ))
142+ token = get_input_compat ("github-token" , required = True )
143+ sha = get_input_compat ("sha" , required = True ).strip ()
144+ trigger_event = get_input_compat ("trigger-event" )
145+ head_branch = get_input_compat ("head-branch" )
146+ is_fork = (get_input_compat ("is-fork" ) or "false" ).strip ().lower () == "true"
147+ skip_hotfix = (get_input_compat ("skip-hotfix" ) or "false" ).strip ().lower () == "true"
148+ skip_forks = (get_input_compat ("skip-forks" ) or "false" ).strip ().lower () == "true"
149+ require_trigger_event = (get_input_compat ("require-trigger-event" ) or "" ).strip ()
150+ build_workflow_file = get_input_compat ("build-workflow-file" , required = True ).strip ()
151+ artifact_name = get_input_compat ("artifact-name" , required = True ).strip ()
152+ required_workflows = parse_required_workflows (get_input_compat ("required-workflows-json" , required = True ))
128153
129154 if require_trigger_event and trigger_event and trigger_event != require_trigger_event :
130155 core .notice (
0 commit comments