diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..8f6bf64 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,32 @@ +--- +kind: pipeline +type: kubernetes +name: bringCookies + +steps: + + - name: build image + image: plugins/kaniko + settings: + dockerfile: Dockerfile + repo: katharina1602/drone-nextcloud + username: + from_secret: userdockerhub + password: + from_secret: passworddockerhub + tag: + - latest + - ${DRONE_COMMIT_SHA} + + - name: test plugin + image: katharina1602/drone-nextcloud:${DRONE_COMMIT_SHA} + settings: + sourcepath: BringCookies/main.py + destinationpath: TestSourceCode/main.py + nextcloudinstance: cloud.uploadfilter24.eu + user: + from_secret: usernextcloud + password: + from_secret: passwordnextcloud + protocol: https + verifytls: true \ No newline at end of file diff --git a/BringCookies/main.py b/BringCookies/main.py new file mode 100644 index 0000000..d2730d9 --- /dev/null +++ b/BringCookies/main.py @@ -0,0 +1,20 @@ +import os +import requests + +def main(): + env = os.environ + sourcePath = env["PLUGIN_SOURCEPATH"] + destinationPath = env["PLUGIN_DESTINATIONPATH"] + nextcloudInstance = env["PLUGIN_NEXTCLOUDINSTANCE"] + user = env["PLUGIN_USER"] + password = env["PLUGIN_PASSWORD"] + protocol = env["PLUGIN_PROTOCOL"] + verifyTls = env["PLUGIN_VERIFYTLS"] + filecontent = open(sourcePath, "rb") + copy(nextcloudInstance, user, destinationPath, filecontent, password, protocol, verifyTls) + +def copy(nc, user, pathtofile, filecontent, password, protocol, verifyTls): + journey = requests.put(protocol + "://" + nc + "/remote.php/dav/files/" + user + "/" + pathtofile, data=filecontent, auth=(user, password), verify=verifyTls) + +if __name__ == "__main__": + main() diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5bbd3c1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.10.0-alpine3.14 + +RUN mkdir -p /opt/drone/ + +COPY requirements.txt /opt/drone/ + +WORKDIR /opt/drone/ + +RUN pip install -r requirements.txt + +COPY BringCookies /opt/drone/ + +ENTRYPOINT [ "python", "/opt/drone/BringCookies/main.py" ] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file