diff --git a/run b/run index 8fcc1e9..230d025 100755 --- a/run +++ b/run @@ -23,21 +23,33 @@ def apply_key_permissions(keyfile): run(["Icacls", keyfile, "/c", "/t", "/Remove:g", other_user]) run(["Icacls", keyfile]) -def deploy(source, target, keyfile): +def deploy(source, target, auth): for source_file in glob.glob(source): - print(f">> {source_file} -> {target}") - run(["scp", "-i", keyfile, "-o", "StrictHostKeyChecking=no", "-o", "PasswordAuthentication=no", "-r", source_file, target], check=True) + deploy_file(source_file, target, auth) + +def deploy_file(source_file, target, auth): + print(f">> {source_file} -> {target}") + if target.startswith("http://") or target.startswith("https://"): + run(["curl", "--user", auth, target, "--upload-file", source_file], check=True) + else: + run(["scp", "-i", auth, "-o", "StrictHostKeyChecking=no", "-o", "PasswordAuthentication=no", "-r", source_file, target], check=True) temp_file_name = None +auth = None try: - with tempfile.NamedTemporaryFile(delete=False) as deploy_key: - temp_file_name = deploy_key.name - deploy_key.write(os.environ['PLUGIN_KEY'].encode()) - deploy_key.write(b"\n") - deploy_key.close() + if 'PLUGIN_KEY' in os.environ: + with tempfile.NamedTemporaryFile(delete=False) as deploy_key: + temp_file_name = deploy_key.name + deploy_key.write(os.environ['PLUGIN_KEY'].encode()) + deploy_key.write(b"\n") + deploy_key.close() - apply_key_permissions(deploy_key.name) - deploy(SOURCE, TARGET, deploy_key.name) + apply_key_permissions(deploy_key.name) + auth = deploy_key.name + else: + auth = os.environ['PLUGIN_AUTHENTICATION'] + + deploy(SOURCE, TARGET, auth) finally: if temp_file_name is not None: os.remove(temp_file_name)