From 481de753b1f751e954287c4fcb0d94b2839f1c3a Mon Sep 17 00:00:00 2001 From: Gottfried Mayer Date: Mon, 8 Aug 2022 11:20:08 +0200 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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