Skip to content

Commit c5cbd28

Browse files
committed
updated script..
1 parent f7a0e55 commit c5cbd28

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

azure/common/deploy-stage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ stages:
249249
echo Working: $(Pipeline.Workspace)/s/${{ parameters.service_name }}/$(SERVICE_ARTIFACT_NAME)
250250
251251
pip install boto3
252+
pip install json
252253
253254
python copy_spec.py "nhsd-apm-management-ptl-proxygen" "${{ parameters.service_name }}" "$(Pipeline.Workspace)/s/${{ parameters.service_name }}/$(SERVICE_ARTIFACT_NAME)"
254255
displayName: Copy Spec

scripts/copy_spec.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
import os
33
import sys
44
import boto3
5+
import json
56
from pathlib import Path
67
from botocore.exceptions import ClientError
78

89
def 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

Comments
 (0)