diff --git a/scripts/ci/upload_artifact.py b/scripts/ci/upload_artifact.py index 649e13acb0..7ab63fe449 100755 --- a/scripts/ci/upload_artifact.py +++ b/scripts/ci/upload_artifact.py @@ -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")