diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c04a060 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:latest + +LABEL version="1.0.0" +LABEL repository="https://github.com/SamKirkland/FTP-Deploy-Action" +LABEL homepage="https://github.com/SamKirkland/FTP-Deploy-Action" +LABEL maintainer="Sam Kirkland " + +LABEL "com.github.actions.name"="FTP Deploy Action" +LABEL "com.github.actions.description"="Deploy your website via FTP" +LABEL "com.github.actions.icon"="upload-cloud" +LABEL "com.github.actions.color"="orange" + +RUN apk add lftp + +COPY entrypoint.sh /entrypoint.sh +RUN chmod 777 entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..842bc23 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# FTP Deploy for GitHub Actions + +Automate deploying websites and more with this GitHub action. + +![Action](images/action.png) + +### Usage +``` +action "FTP-Deploy-Action" { + uses = "SamKirkland/FTP-Deploy-Action@master" + secrets = ["FTP_USERNAME", "FTP_PASSWORD", "FTP_SERVER"] +} +``` + +1. Select the repository you want to add the action to +2. Select the actions tab `(currently only for beta testers)` +3. Select `Create a new workflow` +4. Select `Edit new file` +5. Paste the above code into the bottom of the file +6. Go back to the `Visual editor` +7. Click edit on the `FTP-Deploy-Action` +8. In the `secrets` section add the required params + * FTP_USERNAME + * FTP_PASSWORD + * FTP_SERVER + * (see optional settings below) + +### Settings +- Options + - __FTP Username__: ${FTP_USERNAME} + - __FTP Password__: ${FTP_PASSWORD} + - __FTP Server__: ${FTP_SERVER} + - __(Optional) Local Dir__: ${LOCAL_DIR} + - __(Optional) Remote Dir__: ${REMOTE_DIR} +- Set actions by editing the action then adding them in the `secrets` section: + - ![Action](images/env.png) + + +### Explination of steps +- This action is triggered by a `event` on your repo +- A docker image based on `mwienk/docker-lftp` is spun up on github servers +- The docker container compresses your code into a tar.gz file +- The file is then uploaded to the remote server +- The file is then un-zipped + +### Debugging locally +###### Instructions for windows +- Install docker for windows +- Open powershell +- Navigate to the repo folder +- Run `docker build --tag action .` +- (Optional) This step is only required when editing entrypoint.sh due to windows editors saving the file with windows line breaks instead of linux line breaks + - Download http://dos2unix.sourceforge.net/ + - In another powershell window nagivate to the dos2unix folder /bin + - Run this command every time you modify entrypoint.sh `.\dos2unix.exe "{FULL_PATH_TO_REPO\entrypoint.sh}"` +- Run `docker run action` + +###### Instructions for linux +- Please submit a PR for linux instructions :) + + +### ToDo +- More config options + - Deploy Mode: ${DEPLOY_MODE} `full`|`diffs` +- SSH support +- Switch from lftp to git + +Pull Requests Welcome! + +### License +---- + +MIT diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..0f332ed --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# "to avoid continuing when errors or undefined variables are present" +set -eu + +echo "Starting FTP Deploy" +echo "Uploading files..." + +WDEFAULT_LOCAL_DIR=${LOCAL_DIR:-"."} +WDEFAULT_REMOTE_DIR=${REMOTE_DIR:-"."} + +lftp $FTP_SERVER -u $FTP_USERNAME,$FTP_PASSWORD -e "set ftp:ssl-allow no; mirror -R $WDEFAULT_LOCAL_DIR $WDEFAULT_REMOTE_DIR; quit" + +echo "FTP Deploy Complete" +exit 0 \ No newline at end of file diff --git a/images/action.png b/images/action.png new file mode 100644 index 0000000..4ae9832 Binary files /dev/null and b/images/action.png differ diff --git a/images/env.png b/images/env.png new file mode 100644 index 0000000..18fbfa9 Binary files /dev/null and b/images/env.png differ