Merge pull request #29 from fuse314/pre-post-actions

Pre/post actions
This commit is contained in:
Christoph Schlosser 2022-08-20 16:44:04 +02:00 committed by GitHub
commit 6b1af9d61e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -34,8 +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)
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

View File

@ -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