From 0aee6b5f7a1092fa86d0022e76d28054bce6410f Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Wed, 12 Sep 2018 22:10:49 +0200 Subject: [PATCH 01/23] Include option to upload only new files --- upload.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/upload.sh b/upload.sh index f16fd66..469911c 100755 --- a/upload.sh +++ b/upload.sh @@ -32,6 +32,12 @@ else PLUGIN_CHMOD="" fi +if [ "$PLUGIN_ONLY_NEWER" = true ]; then + PLUGIN_ONLY_NEWER="-n" +else + PLUGIN_ONLY_NEWER="" +fi + if [ "$PLUGIN_CLEAN_DIR" = true ]; then PLUGIN_CLEAN_DIR="rm -r $PLUGIN_DEST_DIR" else @@ -57,5 +63,5 @@ lftp -e "set xfer:log 1; \ set ssl:verify-certificate $PLUGIN_VERIFY; \ set ssl:check-hostname $PLUGIN_VERIFY; \ $PLUGIN_CLEAN_DIR; \ - mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR" \ + mirror --verbose $PLUGIN_CHMOD $PLUGIN_ONLY_NEWER -R $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR" \ -u $FTP_USERNAME,$FTP_PASSWORD $PLUGIN_HOSTNAME From e2827d98d7f4718e8761d6ed6ce8d4fbe6e2bf52 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sun, 16 Sep 2018 16:08:27 +0200 Subject: [PATCH 02/23] Add -e option to only newer --- upload.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload.sh b/upload.sh index 469911c..cba498e 100755 --- a/upload.sh +++ b/upload.sh @@ -33,7 +33,7 @@ else fi if [ "$PLUGIN_ONLY_NEWER" = true ]; then - PLUGIN_ONLY_NEWER="-n" + PLUGIN_ONLY_NEWER="-ne" else PLUGIN_ONLY_NEWER="" fi From c7006319a6ff239d8c804adf4e22e6b82f9d81ff Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Tue, 25 Sep 2018 18:38:53 +0200 Subject: [PATCH 03/23] Add ignore timezone and twice -R --- upload.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload.sh b/upload.sh index cba498e..d6817b1 100755 --- a/upload.sh +++ b/upload.sh @@ -33,7 +33,7 @@ else fi if [ "$PLUGIN_ONLY_NEWER" = true ]; then - PLUGIN_ONLY_NEWER="-ne" + PLUGIN_ONLY_NEWER="-Rne --ignore-time" else PLUGIN_ONLY_NEWER="" fi From f99d405a712d96ed0baa8a059062df9933a14934 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Fri, 17 May 2019 20:15:51 +0200 Subject: [PATCH 04/23] Update README to drone 1.0.0 --- README.md | 91 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 3bdc8a6..65355f8 100644 --- a/README.md +++ b/README.md @@ -9,53 +9,64 @@ You have to set the username and password for your FTP server in the `FTP_USERNAME` and `FTP_PASSWORD` secret. -### Basic + +## Optional settings ```yaml -pipeline: - deploy: - image: cschlosser/drone-ftps - hostname: example.com:21 - secrets: [ ftp_username, ftp_password ] +environment: + FTP_USERNAME: + from_secret: username + FTP_PASSWORD: + from_secret: password + PLUGIN_HOSTNAME: example.com:21 + PLUGIN_DEST_DIR: /path/to/dest (default /) + PLUGIN_SRC_DIR: /path/to/dest (default ./) + PLUGIN_SECURE: true | false (default true) + PLUGIN_VERIFY: false + PLUGIN_EXCLUDE: (egrep like pattern matching) + PLUGIN_INCLUDE: (egrep like pattern matching) ``` -### Optional settings +## Full file example ```yaml -secure: true | false (default true) +kind: pipeline +name: default -dest_dir: /path/to/dest (default /) +steps: +- name: master_build + image: cschlosser/drone-ftps + environment: + FTP_USERNAME: + from_secret: username + FTP_PASSWORD: + from_secret: password + PLUGIN_HOSTNAME: example.com:21 -src_dir: /path/to/src (default ./) + PLUGIN_SECURE: false + PLUGIN_VERIFY: false + PLUGIN_EXCLUDE: ^\.git/$ + when: + branch: + - master + event: + - push -exclude: (egrep like pattern matching) - - ^\.git/$ - - ^\.gitignore$ - - ^\.drone.yml$ - -include: like exclude -``` - -Full file: - -```yaml -pipeline: - deploy: - image: cschlosser/drone-ftps - hostname: example.com:21 - secrets: [ ftp_username, ftp_password ] - secure: true (default) | false # true = use FTP(S), false = FTP without SSL - verify: true (default) | false # true = strong SSL verification, false = supress SSL verification error - chmod: true (default) | false # true = chmod after file transferred, false = no chmod after file transferred - clean_dir: true | false (default) # true = clean destination directory before transferring files, false = don't clean - dest_dir: /var/www/mysite - src_dir: /mysite/static - exclude: - - ^\.git/$ - - ^\.gitignore$ - - ^\.drone.yml$ - include: - - ^*.css$ - - ^*.js$ - - ^*.html$ +- name: develop_build + image: cschlosser/drone-ftps + environment: + FTP_USERNAME: + from_secret: username + FTP_PASSWORD: + from_secret: password + PLUGIN_HOSTNAME: example.com:21 + PLUGIN_DEST_DIR: /develop + PLUGIN_SECURE: false + PLUGIN_VERIFY: false + PLUGIN_EXCLUDE: ^\.git/$ + when: + branch: + - develop + event: + - push ``` From 022ff94a9c4c9eb797077f1d9ee5f62614655e96 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Fri, 17 May 2019 20:17:33 +0200 Subject: [PATCH 05/23] Required vs optional --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 65355f8..8af833c 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ You have to set the username and password for your FTP server in the `FTP_USERNAME` and `FTP_PASSWORD` secret. - -## Optional settings +## Required settings ```yaml environment: @@ -19,6 +18,12 @@ environment: FTP_PASSWORD: from_secret: password PLUGIN_HOSTNAME: example.com:21 +``` + +## Optional settings + +```yaml +environment: PLUGIN_DEST_DIR: /path/to/dest (default /) PLUGIN_SRC_DIR: /path/to/dest (default ./) PLUGIN_SECURE: true | false (default true) From 892aad07210eca9418f31466c3a9f655b02ac484 Mon Sep 17 00:00:00 2001 From: Vladimir Yakovlev Date: Sat, 28 Mar 2020 00:50:40 +0300 Subject: [PATCH 06/23] FTP connection max retries --- upload.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/upload.sh b/upload.sh index f16fd66..6b9fdf0 100755 --- a/upload.sh +++ b/upload.sh @@ -56,6 +56,7 @@ lftp -e "set xfer:log 1; \ set ftp:ssl-protect-data $PLUGIN_SECURE; \ set ssl:verify-certificate $PLUGIN_VERIFY; \ set ssl:check-hostname $PLUGIN_VERIFY; \ + set net:max-retries 3; \ $PLUGIN_CLEAN_DIR; \ mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR" \ -u $FTP_USERNAME,$FTP_PASSWORD $PLUGIN_HOSTNAME From 785fccfb032f8ba18fed9bdd51e3e3d7e4ca0074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20V=C3=A1zquez=20Viader?= Date: Sat, 24 Oct 2020 19:05:03 +0200 Subject: [PATCH 07/23] For use regexp in include/exclude, it is needed to surround expresion in single quotes --- upload.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upload.sh b/upload.sh index 6b9fdf0..b79aa14 100755 --- a/upload.sh +++ b/upload.sh @@ -43,11 +43,11 @@ PLUGIN_INCLUDE_STR="" IFS=',' read -ra in_arr <<< "$PLUGIN_EXCLUDE" for i in "${in_arr[@]}"; do - PLUGIN_EXCLUDE_STR="$PLUGIN_EXCLUDE_STR -x $i" + PLUGIN_EXCLUDE_STR="$PLUGIN_EXCLUDE_STR -x '$i'" done IFS=',' read -ra in_arr <<< "$PLUGIN_INCLUDE" for i in "${in_arr[@]}"; do - PLUGIN_INCLUDE_STR="$PLUGIN_INCLUDE_STR -i $i" + PLUGIN_INCLUDE_STR="$PLUGIN_INCLUDE_STR -i '$i'" done lftp -e "set xfer:log 1; \ From a625c2107f376d56176910edcce39e8792438e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20V=C3=A1zquez=20Viader?= Date: Sat, 24 Oct 2020 19:39:37 +0200 Subject: [PATCH 08/23] Added option to send custom options to mirror --- upload.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload.sh b/upload.sh index b79aa14..2927f7e 100755 --- a/upload.sh +++ b/upload.sh @@ -58,5 +58,5 @@ lftp -e "set xfer:log 1; \ set ssl:check-hostname $PLUGIN_VERIFY; \ set net:max-retries 3; \ $PLUGIN_CLEAN_DIR; \ - mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR" \ + mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_MIRROR_OPTS $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR" \ -u $FTP_USERNAME,$FTP_PASSWORD $PLUGIN_HOSTNAME From 9a83d2192e7e8c74f2738e52e994b46e63a5eae6 Mon Sep 17 00:00:00 2001 From: bouni Date: Wed, 18 May 2022 09:22:09 +0000 Subject: [PATCH 09/23] Add openssh to Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 8005c23..eba6ecf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM alpine:edge RUN apk --no-cache add \ + openssh \ libressl \ lftp \ bash From 6dd895b3a02e21be73e2aedf0fc80bdecb167b6c Mon Sep 17 00:00:00 2001 From: bouni Date: Wed, 18 May 2022 09:22:49 +0000 Subject: [PATCH 10/23] add PLUGIN_DEBUG and PLUGIN_AUTO_CONFIRM options --- upload.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/upload.sh b/upload.sh index 2927f7e..b3aca91 100755 --- a/upload.sh +++ b/upload.sh @@ -38,6 +38,18 @@ else PLUGIN_CLEAN_DIR="" fi +if [ -z "$PLUGIN_DEBUG" ]; then + PLUGIN_DEBUG="" +else + PLUGIN_DEBUG="-d" +fi + +if [ -n "$PLUGIN_AUTO_CONFIRM" ]; then + PLUGIN_AUTO_CONFIRM="true" +else + PLUGIN_AUTO_CONFIRM="false" +fi + PLUGIN_EXCLUDE_STR="" PLUGIN_INCLUDE_STR="" @@ -50,10 +62,11 @@ for i in "${in_arr[@]}"; do PLUGIN_INCLUDE_STR="$PLUGIN_INCLUDE_STR -i '$i'" done -lftp -e "set xfer:log 1; \ +lftp $PLUGIN_DEBUG -e "set xfer:log 1; \ set ftp:ssl-allow $PLUGIN_SECURE; \ set ftp:ssl-force $PLUGIN_SECURE; \ set ftp:ssl-protect-data $PLUGIN_SECURE; \ + set sftp:auto-confirm $PLUGIN_AUTO_CONFIRM; \ set ssl:verify-certificate $PLUGIN_VERIFY; \ set ssl:check-hostname $PLUGIN_VERIFY; \ set net:max-retries 3; \ From 28fecde917f4196a2c84bf1ac5b837235d75ca84 Mon Sep 17 00:00:00 2001 From: bouni Date: Wed, 18 May 2022 09:26:46 +0000 Subject: [PATCH 11/23] Extended README with missing and new options --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8af833c..80e8177 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ environment: PLUGIN_VERIFY: false PLUGIN_EXCLUDE: (egrep like pattern matching) PLUGIN_INCLUDE: (egrep like pattern matching) + PLUGIN_CHMOD: true | false (default true) + PLUGIN_CLEAN_DIR: true | false (default false) + PLUGIN_AUTO_CONFIRM: true | false (default false) + PLUGIN_DEBUG: true | false (default false) ``` ## Full file example From 9a67c805e1a8a2d5ba9a3263dd0a1b0c7b4bffa2 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser <2466365+cschlosser@users.noreply.github.com> Date: Thu, 26 May 2022 22:06:18 +0200 Subject: [PATCH 12/23] Create docker.yml --- .github/workflows/docker.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..36d1de1 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,25 @@ +name: Docker Image + +on: + push: + branches: [ master ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: cschlosser/drone-ftps From ec9c488494e978efca0f97c85fb9228b9d7d54cf Mon Sep 17 00:00:00 2001 From: bouni Date: Wed, 27 Jul 2022 08:14:19 +0200 Subject: [PATCH 13/23] Update badges --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 80e8177..74d22ef 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Deploy to FTP(S) server from Drone CI -[![Docker Stars](https://img.shields.io/docker/stars/cschlosser/drone-ftps.svg)](https://hub.docker.com/r/cschlosser/drone-ftps/) -[![Docker Pulls](https://img.shields.io/docker/pulls/cschlosser/drone-ftps.svg)](https://hub.docker.com/r/cschlosser/drone-ftps/) -[![Docker Build](https://img.shields.io/docker/build/cschlosser/drone-ftps.svg)](https://hub.docker.com/r/cschlosser/drone-ftps/) -[![Docker Layers](https://images.microbadger.com/badges/image/cschlosser/drone-ftps.svg)](https://hub.docker.com/r/cschlosser/drone-ftps/) +[![Docker Stars](https://badgen.net/docker/stars/cschlosser/drone-ftps)](https://hub.docker.com/r/cschlosser/drone-ftps/) +[![Docker Pulls](https://badgen.net/docker/pulls/cschlosser/drone-ftps)](https://hub.docker.com/r/cschlosser/drone-ftps/) +[![Docker Build](https://img.shields.io/docker/cloud/build/cschlosser/drone-ftps)](https://hub.docker.com/r/cschlosser/drone-ftps/) +[![Docker Size](https://badgen.net/docker/size/cschlosser/drone-ftps)](https://hub.docker.com/r/cschlosser/drone-ftps/) ## Usage From 3c4e54f0dd6a2dc8ab96749f41c40bf455d7e110 Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Fri, 5 Aug 2022 17:51:01 +0200 Subject: [PATCH 14/23] create .ssh directory --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eba6ecf..2605236 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,6 @@ RUN apk --no-cache add \ bash ADD upload.sh /bin/ -RUN chmod +x /bin/upload.sh +RUN chmod +x /bin/upload.sh && mkdir ~/.ssh && chmod 700 ~/.ssh ENTRYPOINT /bin/upload.sh From 70452fab5cb83f5a79e05262dd11e1a5562151e9 Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Fri, 5 Aug 2022 17:55:07 +0200 Subject: [PATCH 15/23] new parameter PLUGIN_SSH_ACCEPT_RSA --- upload.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/upload.sh b/upload.sh index b3aca91..ffd3d0b 100755 --- a/upload.sh +++ b/upload.sh @@ -50,6 +50,10 @@ else PLUGIN_AUTO_CONFIRM="false" fi +if [ "$PLUGIN_SSH_ACCEPT_RSA" = true ]; then + echo "HostKeyAlgorithms ssh-rsa" > ~/.ssh/config && echo "PubkeyAcceptedKeyTypes ssh-rsa" >> ~/.ssh/config && chmod 600 ~/.ssh/config +fi; + PLUGIN_EXCLUDE_STR="" PLUGIN_INCLUDE_STR="" From 4f4063bf9e03ab5f1af620dbc5a99601dbc9bc51 Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Fri, 5 Aug 2022 21:25:13 +0200 Subject: [PATCH 16/23] document new parameter PLUGIN_SSH_ACCEPT_RSA --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 80e8177..cea0d02 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ environment: PLUGIN_CHMOD: true | false (default true) PLUGIN_CLEAN_DIR: true | false (default false) PLUGIN_AUTO_CONFIRM: true | false (default false) + PLUGIN_SSH_ACCEPT_RSA: true | false (default false) PLUGIN_DEBUG: true | false (default false) ``` From 481de753b1f751e954287c4fcb0d94b2839f1c3a Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Mon, 8 Aug 2022 11:20:08 +0200 Subject: [PATCH 17/23] new parameters PLUGIN_PRE/POST_ACTION --- upload.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/upload.sh b/upload.sh index ffd3d0b..544fac8 100755 --- a/upload.sh +++ b/upload.sh @@ -74,6 +74,8 @@ lftp $PLUGIN_DEBUG -e "set xfer:log 1; \ set ssl:verify-certificate $PLUGIN_VERIFY; \ set ssl:check-hostname $PLUGIN_VERIFY; \ set net:max-retries 3; \ + $PLUGIN_PRE_ACTION; \ $PLUGIN_CLEAN_DIR; \ - mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_MIRROR_OPTS $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR" \ + mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_MIRROR_OPTS $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR; \ + $PLUGIN_POST_ACTION;" \ -u $FTP_USERNAME,$FTP_PASSWORD $PLUGIN_HOSTNAME From 431c98295b940161bdb702d2c5d141595bb3ac70 Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Mon, 8 Aug 2022 11:22:07 +0200 Subject: [PATCH 18/23] document new parameters --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cea0d02..57639ff 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ environment: PLUGIN_CLEAN_DIR: true | false (default false) PLUGIN_AUTO_CONFIRM: true | false (default false) PLUGIN_SSH_ACCEPT_RSA: true | false (default false) + PLUGIN_PRE_ACTION: string (default empty, example: mv /dest/logs /temp/logs) + PLUGIN_POST_ACTION: string (default empty, example: mv /temp/logs /dest/logs) PLUGIN_DEBUG: true | false (default false) ``` From 51da955bfc0784a3561d45c7dc4a56e53fe8f301 Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Thu, 18 Aug 2022 11:56:12 +0200 Subject: [PATCH 19/23] describe pre/post actions with an example --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b223f5..5120fb8 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,23 @@ environment: PLUGIN_CLEAN_DIR: true | false (default false) PLUGIN_AUTO_CONFIRM: true | false (default false) PLUGIN_SSH_ACCEPT_RSA: true | false (default false) - PLUGIN_PRE_ACTION: string (default empty, example: mv /dest/logs /temp/logs) - PLUGIN_POST_ACTION: string (default empty, example: mv /temp/logs /dest/logs) + PLUGIN_PRE_ACTION: string (default empty) + PLUGIN_POST_ACTION: string (default empty) PLUGIN_DEBUG: true | false (default false) ``` +### Pre/Post Action +Pre/Post Action can be used to move files/folders out of the way or execute additional commands on the server before and after the deployment process. +The `PLUGIN_PRE_ACTION` is executed *before* the `PLUGIN_CLEAN_DIR` (if set). +The `PLUGIN_POST_ACTION` is executed *after* the ftp "mirror" operation. + +Multiple Actions can be set, they need to be divided by a semicolon `;` . +**Example:** +There is another project's folder ("project2") in a subfolder in the destination directory. We need to move this folder to a temporary location and restore it after the upload completed. +```yaml +PLUGIN_CLEAN_DIR: true +PLUGIN_PRE_ACTION: mv /dest/project2 /temp/project2; +PLUGIN_POST_ACTION: mv /temp/project2 /dest/project2; +``` ## Full file example From 42ec53a83b911fcc8bc1daa005105d3bab80659e Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Mon, 31 Oct 2022 14:39:38 +0100 Subject: [PATCH 20/23] new parameter PLUGIN_ONLY NEWER - only uploads newer files (mirror parameter -n) - ignores timestamp due to time differences between local and remote system (mirror parameter --ignore time) - removes any files/folders from the server that are not present in the source directory (mirror parameter -e) --- upload.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/upload.sh b/upload.sh index 544fac8..b61dde9 100755 --- a/upload.sh +++ b/upload.sh @@ -32,6 +32,12 @@ else PLUGIN_CHMOD="" fi +if [ "$PLUGIN_ONLY_NEWER" = true ]; then + PLUGIN_ONLY_NEWER="-e -n --ignore-time" +else + PLUGIN_ONLY_NEWER="" +fi + if [ "$PLUGIN_CLEAN_DIR" = true ]; then PLUGIN_CLEAN_DIR="rm -r $PLUGIN_DEST_DIR" else @@ -76,6 +82,6 @@ lftp $PLUGIN_DEBUG -e "set xfer:log 1; \ set net:max-retries 3; \ $PLUGIN_PRE_ACTION; \ $PLUGIN_CLEAN_DIR; \ - mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_MIRROR_OPTS $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR; \ + mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_ONLY_NEWER $PLUGIN_MIRROR_OPTS $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR; \ $PLUGIN_POST_ACTION;" \ -u $FTP_USERNAME,$FTP_PASSWORD $PLUGIN_HOSTNAME From ae476dce41df8a157c17a8541fe7a802272782e4 Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Mon, 31 Oct 2022 14:55:51 +0100 Subject: [PATCH 21/23] document PLUGIN_ONLY_NEWER parameter --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5120fb8..cf80e30 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ environment: PLUGIN_INCLUDE: (egrep like pattern matching) PLUGIN_CHMOD: true | false (default true) PLUGIN_CLEAN_DIR: true | false (default false) + PLUGIN_ONLY_NEWER: true | false (default false) PLUGIN_AUTO_CONFIRM: true | false (default false) PLUGIN_SSH_ACCEPT_RSA: true | false (default false) PLUGIN_PRE_ACTION: string (default empty) @@ -44,7 +45,7 @@ The `PLUGIN_PRE_ACTION` is executed *before* the `PLUGIN_CLEAN_DIR` (if set). The `PLUGIN_POST_ACTION` is executed *after* the ftp "mirror" operation. Multiple Actions can be set, they need to be divided by a semicolon `;` . -**Example:** +#### Example: There is another project's folder ("project2") in a subfolder in the destination directory. We need to move this folder to a temporary location and restore it after the upload completed. ```yaml PLUGIN_CLEAN_DIR: true @@ -52,6 +53,15 @@ PLUGIN_PRE_ACTION: mv /dest/project2 /temp/project2; PLUGIN_POST_ACTION: mv /temp/project2 /dest/project2; ``` +### Transfer only newer files +The setting `PLUGIN_ONLY_NEWER: true` (only transfer newer files) does not mix well with the `PLUGIN_CLEAN_DIR: true` (clean destination directory before transfer). + +When setting `PLUGIN_ONLY_NEWER: true` parameter to true, make sure to _exclude_ any files/folders that are not present in the source directory, but should be kept on the server. +#### Example: +Source folder does not contain an `.env` file, it exists on the remote server and should be kept. +Also, we do not want to transfer the source's `.git` folder and `.gitignore` file: +Set `PLUGIN_ONLY_NEWER: true` and `PLUGIN_EXCLUDE: ^\.git/$,^\.gitignore$,^\.env$` environment variables. + ## Full file example ```yaml From db24bc0bdd24420c6e7e0f173190a4edc12c42a8 Mon Sep 17 00:00:00 2001 From: rubenelshof Date: Fri, 28 Oct 2022 13:48:19 +0200 Subject: [PATCH 22/23] Add PLUGIN_FTP_USERNAME & PLUGIN_FTP_PASSWORD --- upload.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/upload.sh b/upload.sh index b61dde9..70bc29e 100755 --- a/upload.sh +++ b/upload.sh @@ -1,10 +1,16 @@ #!/bin/bash -if [ -z "$FTP_USERNAME" ]; then +if [[ -z "$FTP_USERNAME" && -z "$PLUGIN_FTP_USERNAME" ]]; then echo "Need to set username" exit 1 fi +FTP_USERNAME_STR="" +FTP_PASSWORD_STR="" + +[ -n "$PLUGIN_FTP_USERNAME" ] && FTP_USERNAME_STR="$PLUGIN_FTP_USERNAME" || FTP_USERNAME_STR="$FTP_USERNAME" +[ -n "$PLUGIN_FTP_PASSWORD" ] && FTP_PASSWORD_STR="$PLUGIN_FTP_PASSWORD" || FTP_PASSWORD_STR="$FTP_PASSWORD" + if [ -z "$PLUGIN_HOSTNAME" ]; then echo "Need to set hostname" exit 1 @@ -84,4 +90,4 @@ lftp $PLUGIN_DEBUG -e "set xfer:log 1; \ $PLUGIN_CLEAN_DIR; \ mirror --verbose $PLUGIN_CHMOD -R $PLUGIN_ONLY_NEWER $PLUGIN_MIRROR_OPTS $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR; \ $PLUGIN_POST_ACTION;" \ - -u $FTP_USERNAME,$FTP_PASSWORD $PLUGIN_HOSTNAME + -u "$FTP_USERNAME_STR","$FTP_PASSWORD_STR" "$PLUGIN_HOSTNAME" From 797d0ef6865210dcb6f28c4726a0f16f931d61f0 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 29 Apr 2024 15:28:53 +0200 Subject: [PATCH 23/23] Migrate to drone build --- .drone-manifest.yml | 22 +++++++++ .drone.yml | 92 ++++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 25 ---------- 3 files changed, 114 insertions(+), 25 deletions(-) create mode 100644 .drone-manifest.yml create mode 100644 .drone.yml delete mode 100644 .github/workflows/docker.yml diff --git a/.drone-manifest.yml b/.drone-manifest.yml new file mode 100644 index 0000000..59654fa --- /dev/null +++ b/.drone-manifest.yml @@ -0,0 +1,22 @@ +image: nemunaire/drone-ftps:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - image: nemunaire/drone-ftps:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux + - image: nemunaire/drone-ftps:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64 + platform: + architecture: arm64 + os: linux + variant: v8 + - image: nemunaire/drone-ftps:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm + platform: + architecture: arm + os: linux + variant: v7 diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..56b9245 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,92 @@ +--- +kind: pipeline +type: docker +name: build-amd64 + +platform: + os: linux + arch: amd64 + +steps: +- name: publish on Docker Hub + image: plugins/docker + settings: + repo: nemunaire/drone-ftps + auto_tag: true + auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} + dockerfile: Dockerfile + username: + from_secret: docker_username + password: + from_secret: docker_password + +--- +kind: pipeline +type: docker +name: build-arm64 + +platform: + os: linux + arch: arm64 + +steps: +- name: publish on Docker Hub + image: plugins/docker + settings: + repo: nemunaire/drone-ftps + auto_tag: true + auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} + dockerfile: Dockerfile + username: + from_secret: docker_username + password: + from_secret: docker_password + +--- +kind: pipeline +type: docker +name: build-arm + +platform: + os: linux + arch: arm + +steps: +- name: publish on Docker Hub + image: plugins/docker:linux-arm + settings: + repo: nemunaire/drone-ftps + auto_tag: true + auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} + dockerfile: Dockerfile + username: + from_secret: docker_username + password: + from_secret: docker_password + +--- +kind: pipeline +name: docker-manifest + +steps: +- name: publish on Docker Hub + image: plugins/manifest + settings: + auto_tag: true + ignore_missing: true + spec: .drone-manifest.yml + username: + from_secret: docker_username + password: + from_secret: docker_password + +trigger: + event: + - cron + - push + - tag + +depends_on: +- build-amd64 +- build-arm64 +- build-arm diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 36d1de1..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Docker Image - -on: - push: - branches: [ master ] - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Log in to Docker Hub - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - push: true - tags: cschlosser/drone-ftps