@@ -215,6 +215,7 @@ def handle_post( # pylint: disable=too-many-arguments
215215 post_data ["id" ] = post_id
216216 post = create_or_update_post (post_data , headers )
217217 results ["added" if file_path in added_files else "modified" ].append (post )
218+ return results
218219
219220
220221def handle_deleted_post (
@@ -228,14 +229,15 @@ def handle_deleted_post(
228229 success = delete_post (post_id , headers )
229230 if success :
230231 results ["deleted" ].append ({"slug" : metadata ["slug" ]})
232+ return results
231233
232234
233235def write_results_to_github_output (results : Dict [str , List [Dict [str , str ]]]) -> None :
234236 """Write the results to the GitHub output in two different formats."""
235- github_output_path = os .getenv ("GITHUB_OUTPUT" )
236- with open (github_output_path , "a" , encoding = "utf-8" ) as f :
237- f . write (f"result_json={ json .dumps (results )} \n " )
238- f . write (f"result_summary={ json .dumps (results , indent = 2 )} \n " )
237+ github_output = os .getenv ("GITHUB_OUTPUT" )
238+ with open (github_output , "a" , encoding = "utf-8" ) as output_file :
239+ print (f"result_json={ json .dumps (results )} " , file = output_file )
240+ print (f"result_summary={ json .dumps (results , indent = 2 )} " , file = output_file )
239241
240242
241243def main ():
@@ -262,14 +264,16 @@ def main():
262264
263265 for file_path in added_files :
264266 if file_path .is_relative_to (posts_directory ) and file_path .suffix == ".md" :
265- handle_post (file_path , file_path .parent , repo , branch , publication_id , headers , results , added_files )
267+ results = handle_post (
268+ file_path , file_path .parent , repo , branch , publication_id , headers , results , added_files
269+ )
266270
267271 for file_path in deleted_files :
268272 if file_path .is_relative_to (posts_directory ) and file_path .suffix == ".md" :
269- handle_deleted_post (file_path , publication_id , headers , results )
273+ results = handle_deleted_post (file_path , publication_id , headers , results )
270274
271275 write_results_to_github_output (results )
272276
277+
273278if __name__ == "__main__" :
274279 main ()
275-
0 commit comments