Skip to content

Commit

Permalink
GHA: fix filename extension when uploading tarballs
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniofrighetto committed Jan 18, 2025
1 parent 7644a56 commit ceaef35
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .github/scripts/s3-deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,20 @@ def get_tag(ci):
)

def push(file: str, dir_name: str, s3_bucket_name: str, s3_resource, s3_content_type: str, use_timestamp=True):
zipfile = pathlib.Path(file)
path = pathlib.Path(file)
if use_timestamp:
ext = ''.join(path.suffixes)
base = path.name[:-len(ext)] if ext else path.name
now = datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
dst = f"{dir_name}/{zipfile.stem}_{now}{zipfile.suffix}"
dest_filename = f"{base}_{now}{ext}"
else:
dst = f"{dir_name}/{zipfile.name}"
logger.info("Uploading %s to %s", file, dst)
dest_filename = path.name

dest = f"{dir_name}/{dest_filename}"
logger.info("Uploading %s to %s", file, dest)
try:
obj = s3_resource.Object(s3_bucket_name, dst)
obj.put(Body=zipfile.read_bytes(), ContentType=s3_content_type)
obj = s3_resource.Object(s3_bucket_name, dest)
obj.put(Body=path.read_bytes(), ContentType=s3_content_type)
return 0
except ClientError as e:
logger.error("S3 push failed: %s", e)
Expand Down

0 comments on commit ceaef35

Please sign in to comment.