@@ -74,6 +74,11 @@ def write_yaml(path: Path, yaml_dict: dict | list):
7474 yaml = ruyaml .YAML ()
7575 yaml .dump (yaml_dict , file )
7676
77+ def to_yaml_string (yaml_dict : dict | list ):
78+ yaml = ruyaml .YAML ()
79+ stream = StringIO ()
80+ yaml .dump (yaml_dict , stream )
81+ return stream .getvalue ()
7782
7883def write_str (path : Path , content : str ):
7984 with open (path , "w" ) as file :
@@ -190,11 +195,9 @@ def update_actions(dummy_path: Path, actions_path: Path):
190195 actions : ActionsYAML = load_yaml (actions_path )
191196
192197 update_refs (steps , actions )
193- yaml = ruyaml .YAML ()
194- gha_print (yaml .dump (actions ), "Generated List" )
198+ gha_print (to_yaml_string (actions ), "Generated List" )
195199 write_yaml (actions_path , actions )
196200
197-
198201def create_pattern (actions : ActionsYAML ) -> list [str ]:
199202 """
200203 Create a pattern list of valid action references.
@@ -228,8 +231,7 @@ def update_patterns(pattern_path: Path, list_path: Path):
228231 actions : ActionsYAML = load_yaml (list_path )
229232 patterns = create_pattern (actions )
230233 comment = f"# This file was generated from { pattern_path } by gateway/gateway.py. DO NOT UPDATE MANUALLY.\n "
231- yaml = ruyaml .YAML ()
232- patterns_str = comment + yaml .safe_dump (patterns )
234+ patterns_str = comment + to_yaml_string (patterns )
233235 gha_print (patterns_str , "Generated Patterns" )
234236 write_str (pattern_path , patterns_str )
235237
@@ -283,6 +285,5 @@ def clean_actions(actions_path: Path):
283285 """
284286 actions : ActionsYAML = load_yaml (actions_path )
285287 remove_expired_refs (actions )
286- yaml = ruyaml .YAML ()
287- gha_print (yaml .safe_dump (actions ), "Cleaned Actions" )
288+ gha_print (to_yaml_string (actions ), "Cleaned Actions" )
288289 write_yaml (actions_path , actions )
0 commit comments