Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniofrighetto committed Jan 18, 2025
1 parent 7644a56 commit fdfbe19
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions .github/scripts/s3-deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def get_tag(ci):
logger.info("Branch: %s", BRANCH_NAME)
logger.info("Tag: %s", TAG_NAME)

if BRANCH_NAME.startswith("release-"):
logger.info("Branch release")
elif BRANCH_NAME not in ALLOWED_BRANCHES and not IS_TAGGED:
logger.info("Skip deployment for branch '%s'", BRANCH_NAME)
sys.exit(0)
# if BRANCH_NAME.startswith("release-"):
# logger.info("Branch release")
# elif BRANCH_NAME not in ALLOWED_BRANCHES and not IS_TAGGED:
# logger.info("Skip deployment for branch '%s'", BRANCH_NAME)
# sys.exit(0)

if is_pr(CURRENT_CI):
logger.info("Skip pull request")
Expand Down Expand Up @@ -139,16 +139,19 @@ 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 fdfbe19

Please sign in to comment.