Skip to content

Commit c88ce8b

Browse files
tmp
1 parent 7644a56 commit c88ce8b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

.github/scripts/s3-deploy.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,19 @@ def get_tag(ci):
139139
)
140140

141141
def push(file: str, dir_name: str, s3_bucket_name: str, s3_resource, s3_content_type: str, use_timestamp=True):
142-
zipfile = pathlib.Path(file)
142+
path = pathlib.Path(file)
143143
if use_timestamp:
144+
ext = ''.join(path.suffixes)
145+
base = path.name[:-len(ext)] if ext else path.name
144146
now = datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
145-
dst = f"{dir_name}/{zipfile.stem}_{now}{zipfile.suffix}"
147+
dest_filename = f"{base}_{now}{ext}"
146148
else:
147-
dst = f"{dir_name}/{zipfile.name}"
148-
logger.info("Uploading %s to %s", file, dst)
149+
dest_filename = path.name
150+
dest = f"{dir_name}/{dest_filename}"
151+
logger.info("Uploading %s to %s", file, dest)
149152
try:
150-
obj = s3_resource.Object(s3_bucket_name, dst)
151-
obj.put(Body=zipfile.read_bytes(), ContentType=s3_content_type)
153+
obj = s3_resource.Object(s3_bucket_name, dest)
154+
obj.put(Body=path.read_bytes(), ContentType=s3_content_type)
152155
return 0
153156
except ClientError as e:
154157
logger.error("S3 push failed: %s", e)

0 commit comments

Comments
 (0)