-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Docker files which set up the Action item for Github.
Signed-off-by: Israel Roldan <[email protected]>
- Loading branch information
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM debian:stable-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get -y update && \ | ||
apt-get install -y \ | ||
lftp | ||
|
||
COPY init.sh /app/init.sh | ||
COPY LICENSE README.md /app/ | ||
|
||
ENTRYPOINT ["/app/init.sh"] | ||
#RUN ["/bin/sh", "/app/init.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: 'ftp-deployment-action' | ||
author: 'Israel Roldan <[email protected]>' | ||
description: >- | ||
FTP Deployment: | ||
This GitHub action copy the files via FTP from your Git project to your server in a specific path. | ||
inputs: | ||
server: | ||
description: 'FTP Server' | ||
required: true | ||
user: | ||
description: 'FTP User' | ||
required: true | ||
password: | ||
description: 'FTP Password' | ||
required: true | ||
ssl_allow: | ||
description: 'Allow SSL encryption' | ||
required: false | ||
default: 'false' | ||
use_feat: | ||
description: 'Use FEAT: Determining what extended features the FTP server supports' | ||
required: false | ||
default: 'false' | ||
delete: | ||
description: 'Delete all the files inside of the remote directory.' | ||
required: false | ||
default: 'false' | ||
local_dir: | ||
description: 'Local directory' | ||
required: false | ||
default: '' | ||
remote_dir: | ||
description: 'Remote directory' | ||
required: false | ||
default: '' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
branding: | ||
color: 'blue' | ||
icon: 'upload-cloud' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
# TODO: Add list of excluded delete files in two formats, string separated by space and file. | ||
|
||
INPUT_SERVER=rovisoft.net | ||
[email protected] | ||
INPUT_PASSWORD=OpYfgb5coLyd | ||
INPUT_SSL_ALLOW=false | ||
INPUT_USE_FEAT=false | ||
INPUT_DELETE=true | ||
#INPUT_LOCAL_DIR="" | ||
INPUT_REMOTE_DIR="" | ||
|
||
FTP_SETTINGS='set ftp:ssl-allow '${INPUT_SSL_ALLOW}'; set ftp:use-feat '${INPUT_USE_FEAT}';' | ||
FILE_LIST=remote_ftp_list_$(date "+%s").tmp | ||
|
||
if [ -z "${INPUT_REMOTE_DIR}" ]; then | ||
INPUT_REMOTE_DIR="./" | ||
else | ||
INPUT_REMOTE_DIR="./${INPUT_REMOTE_DIR}/" | ||
fi | ||
|
||
if [ "${INPUT_DELETE}" = "true" ]; then | ||
echo "Deleting from the Server the files and directories with 'lftp'." | ||
echo -e " Path: ${INPUT_REMOTE_DIR}\n" | ||
|
||
rm -f "${FILE_LIST}" | ||
|
||
lftp \ | ||
-u ${INPUT_USER},${INPUT_PASSWORD} \ | ||
${INPUT_SERVER} \ | ||
-e "${FTP_SETTINGS} renlist > ${FILE_LIST}; quit;" | ||
|
||
sed -i 's/^\.$/..\n/g' "${FILE_LIST}" | ||
sed -i ':begin;N;$!b begin;s/\.\.\n//gm' "${FILE_LIST}" | ||
|
||
DELETE_ITEMS="" | ||
while read -r LINE; do | ||
if [ -n "$LINE" ]; then | ||
DELETE_ITEMS=${DELETE_ITEMS}"${INPUT_REMOTE_DIR}$LINE " | ||
fi | ||
done <"${FILE_LIST}" | ||
|
||
rm -f "${FILE_LIST}" | ||
|
||
lftp \ | ||
-u ${INPUT_USER},${INPUT_PASSWORD} \ | ||
${INPUT_SERVER} \ | ||
-e "${FTP_SETTINGS} glob rm -rf ${DELETE_ITEMS} 2>/dev/null; quit;" | ||
fi | ||
|
||
pwd | ||
ls -lha . |