Rewrite deploy plugin in python to attempt to make it cross platform

This commit is contained in:
Captain Beyond
2024-11-16 03:43:47 -06:00
parent e28284a840
commit b34f651503
3 changed files with 20 additions and 8 deletions

0
.drone.yml Normal file → Executable file
View File

0
Dockerfile Normal file → Executable file
View File

28
run
View File

@@ -1,9 +1,21 @@
#!/bin/sh
SOURCE=${PLUGIN_SOURCE:-.}
TARGET=$PLUGIN_TARGET
#!/usr/bin/env python3
import os
import tempfile
import shutil
import glob
from subprocess import run
mkdir /tmp/deploy
cp -Rv $SOURCE /tmp/deploy
echo "$PLUGIN_KEY" > /tmp/deploy.rsa
chmod 0600 /tmp/deploy.rsa
scp -i /tmp/deploy.rsa -o StrictHostKeyChecking=no -r /tmp/deploy/* $TARGET
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)