@@ -128,7 +128,7 @@ def process_markdown(file_path: Path) -> Tuple[Dict[str, Any], str]:
128128 return post .metadata , post .content
129129
130130
131- def validate_frontmatter (metadata : Dict [str , Any ]) -> None :
131+ def get_validated_frontmatter (metadata : Dict [str , Any ]) -> None :
132132 """Validate that the frontmatter contains the required fields."""
133133 required_fields = ["title" ]
134134 for field in required_fields :
@@ -152,6 +152,8 @@ def validate_frontmatter(metadata: Dict[str, Any]) -> None:
152152 if "publishedAt" not in metadata :
153153 metadata ["publishedAt" ] = datetime .now ().isoformat ()
154154
155+ return metadata
156+
155157
156158def convert_path_to_posix (path : Union [str , Path ]) -> str :
157159 """Convert a path to a POSIX path."""
@@ -185,7 +187,12 @@ def handle_post( # pylint: disable=too-many-arguments
185187) -> None :
186188 """Handle a markdown post file."""
187189 metadata , content = process_markdown (file_path )
188- validate_frontmatter (metadata )
190+
191+ try :
192+ metadata = get_validated_frontmatter (metadata )
193+ except ValueError as e :
194+ results ["errors" ].append ({"file" : file_path , "error" : str (e )})
195+ return results
189196
190197 content = update_image_urls (content , base_path , repo , branch )
191198
@@ -264,20 +271,31 @@ def main():
264271 publication_host = os .environ ["PUBLICATION_HOST" ]
265272
266273 # Convert the space-separated strings to lists
267- changed_files = os .environ .get ("CHANGED_FILES" , "" ).split ()
274+ added_files = os .environ .get ("ADDED_FILES" , "" ).split ()
275+ changed_and_modified_files = os .environ .get ("CHANGED_AND_MODIFIED_FILES" , "" ).split ()
268276 deleted_files = os .environ .get ("DELETED_FILES" , "" ).split ()
269277
270278 repo = os .environ ["GITHUB_REPOSITORY" ]
271279 branch = os .environ ["GITHUB_REF" ].split ("/" )[- 1 ]
272- added_files = [Path (f ) for f in changed_files if f ]
280+ added_files = [Path (f ) for f in added_files if f ]
281+ changed_and_modified_files = [Path (f ) for f in changed_and_modified_files if f ]
273282 deleted_files = [Path (f ) for f in deleted_files if f ]
274283
275284 headers = {"Authorization" : f"Bearer { access_token } " }
276285 publication_id = get_publication_id (publication_host , headers )
277286
278- results = {"added" : [], "modified" : [], "deleted" : []}
287+ results = {
288+ "input_added_files" : added_files ,
289+ "input_changed_and_modified_files" : changed_and_modified_files ,
290+ "input_deleted_files" : deleted_files ,
291+ "added" : [],
292+ "modified" : [],
293+ "deleted" : [],
294+ "errors" : [],
295+ }
279296
280- for file_path in added_files :
297+ all_changed_files = added_files + changed_and_modified_files
298+ for file_path in all_changed_files :
281299 if file_path .is_relative_to (posts_directory ) and file_path .suffix == ".md" :
282300 results = handle_post (
283301 file_path , file_path .parent , repo , branch , publication_id , headers , results , added_files
0 commit comments