Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan authored Jul 9, 2024
1 parent de6ba32 commit 947a7ab
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions scripts/ci/upload_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ def upload_files(remote_host, remote_user, remote_port, ssh_private_key, source,

sftp = ssh.open_sftp()
for root, dirs, files in os.walk(source):
relative_dir_path = os.path.relpath(root, source)
remote_dir_path = os.path.join(target, relative_dir_path).replace("\\", "/")
try:
sftp.mkdir(remote_dir_path)
except OSError:
pass # Directory probably already exists

for filename in files:
local_path = os.path.join(root, filename)
remote_path = os.path.join(target, relative_dir_path, filename).replace("\\", "/")
relative_path = os.path.relpath(local_path, source)
remote_path = os.path.join(target, relative_path).replace("\\", "/")

remote_dir = os.path.dirname(remote_path)
try:
sftp.mkdir(remote_dir)
except OSError:
pass # Directory probably already exists

sftp.put(local_path, remote_path)

print("Upload finished successfully")
Expand Down

0 comments on commit 947a7ab

Please sign in to comment.