Rewrite deploy plugin in python to attempt to make it cross platform
This commit is contained in:
0
.drone.yml
Normal file → Executable file
0
.drone.yml
Normal file → Executable file
0
Dockerfile
Normal file → Executable file
0
Dockerfile
Normal file → Executable file
28
run
28
run
@@ -1,9 +1,21 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env python3
|
||||||
SOURCE=${PLUGIN_SOURCE:-.}
|
import os
|
||||||
TARGET=$PLUGIN_TARGET
|
import tempfile
|
||||||
|
import shutil
|
||||||
|
import glob
|
||||||
|
from subprocess import run
|
||||||
|
|
||||||
mkdir /tmp/deploy
|
SOURCE = os.environ.get("PLUGIN_SOURCE", ".")
|
||||||
cp -Rv $SOURCE /tmp/deploy
|
TARGET = os.environ['PLUGIN_TARGET']
|
||||||
echo "$PLUGIN_KEY" > /tmp/deploy.rsa
|
|
||||||
chmod 0600 /tmp/deploy.rsa
|
def deploy(source, target, keyfile):
|
||||||
scp -i /tmp/deploy.rsa -o StrictHostKeyChecking=no -r /tmp/deploy/* $TARGET
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user