diff --git a/run b/run index 6cfb897..51ae074 100755 --- a/run +++ b/run @@ -10,12 +10,19 @@ TARGET = os.environ['PLUGIN_TARGET'] def deploy(source, target, keyfile): for source_file in glob.glob(source): - run(["scp", "-v", "-i", keyfile, "-o", "StrictHostKeyChecking=no", "-r", source_file, target]) + print(f">> {source_file} -> {target}") + run(["scp", "-i", keyfile, "-o", "StrictHostKeyChecking=no", "-r", source_file, target]) -with tempfile.NamedTemporaryFile() as deploy_key: - deploy_key.write(os.environ['PLUGIN_KEY'].encode()) - deploy_key.write(b"\n") - deploy_key.flush() +temp_file_name = 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() - os.chmod(deploy_key.name, 0o600) - deploy(SOURCE, TARGET, deploy_key.name) + os.chmod(deploy_key.name, 0o600) + deploy(SOURCE, TARGET, deploy_key.name) +finally: + if temp_file_name is not None: + os.remove(temp_file_name)