22import os
33import sys
44import boto3
5+ import json
56from pathlib import Path
67from botocore .exceptions import ClientError
78
89def upload_to_s3 (file_path : Path , bucket_name : str , folder_name : str ):
910 """Upload one file to the given S3 bucket under folder_name/."""
1011 s3 = boto3 .client ("s3" )
11- key = f"{ folder_name } /{ file_path } "
12+ key = f"apis/ { folder_name } /{ file_path } "
1213
1314 try :
1415 s3 .upload_file (str (file_path ), bucket_name , key )
15- print (f"[OK] Uploaded → s3://{ bucket_name } /{ key } " )
16+ print (f"[OK] Uploaded → s3://{ bucket_name } /apis/ { key } " )
1617 except ClientError as e :
1718 print (f"[ERROR] Upload failed: { file_path } → s3://{ bucket_name } /{ key } " )
1819 print (e )
@@ -31,15 +32,22 @@ def main(bucket_name: str, repo_name: str, working_directory:str):
3132
3233 root_dir = Path .cwd ().parents [1 ] # go up 2 levels
3334 json_file = root_dir / f"{ repo_name } .json"
35+ minified_json = "spec.json"
3436
3537 print (json_file )
3638
39+ with open (json_file , "r" ) as f :
40+ data = json .load (f )
41+
42+ with open (minified_json , "w" ) as f :
43+ json .dump (data , f , separators = ("," , ":" ))
44+
3745 #json_file = f"{repo_name}.json"
3846
3947 # Build path to JSON file
4048 #json_path = os.path.join(json_dir, json_file)
4149
42- upload_to_s3 (json_file , bucket_name , repo_name )
50+ upload_to_s3 (minified_json , bucket_name , repo_name )
4351
4452 print ("[DONE] Processing complete." )
4553 return 0
0 commit comments