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
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user