Files
web-deploy-plugin/run

22 lines
603 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", "-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)