close deploy key before we pass it into scp, windows won't let us open the file while its already opened
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
since delete_on_close was introduced in Python 3.12 we have to implement manually :(
This commit is contained in:
21
run
21
run
@@ -10,12 +10,19 @@ TARGET = os.environ['PLUGIN_TARGET']
|
|||||||
|
|
||||||
def deploy(source, target, keyfile):
|
def deploy(source, target, keyfile):
|
||||||
for source_file in glob.glob(source):
|
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:
|
temp_file_name = None
|
||||||
deploy_key.write(os.environ['PLUGIN_KEY'].encode())
|
try:
|
||||||
deploy_key.write(b"\n")
|
with tempfile.NamedTemporaryFile(delete=False) as deploy_key:
|
||||||
deploy_key.flush()
|
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)
|
os.chmod(deploy_key.name, 0o600)
|
||||||
deploy(SOURCE, TARGET, deploy_key.name)
|
deploy(SOURCE, TARGET, deploy_key.name)
|
||||||
|
finally:
|
||||||
|
if temp_file_name is not None:
|
||||||
|
os.remove(temp_file_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user