Files
web-deploy-plugin/run
Captain Beyond 1d3da35b3c
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
add logging to scp
2024-11-16 04:03:29 -06:00

22 lines
609 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):
run(["scp", "-v", "-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()
os.chmod(deploy_key.name, 0o600)
deploy(SOURCE, TARGET, deploy_key.name)