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 :(
29 lines
832 B
Python
Executable File
29 lines
832 B
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import tempfile
|
|
import shutil
|
|
import glob
|
|
from subprocess import run
|
|
|
|
SOURCE = os.environ.get("PLUGIN_SOURCE", ".")
|
|
TARGET = os.environ['PLUGIN_TARGET']
|
|
|
|
def deploy(source, target, keyfile):
|
|
for source_file in glob.glob(source):
|
|
print(f">> {source_file} -> {target}")
|
|
run(["scp", "-i", keyfile, "-o", "StrictHostKeyChecking=no", "-r", source_file, target])
|
|
|
|
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)
|
|
finally:
|
|
if temp_file_name is not None:
|
|
os.remove(temp_file_name)
|