Skip to content

Commit d1fda48

Browse files
committed
Initial commit
1 parent b6d9340 commit d1fda48

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM alpine:latest
2+
3+
LABEL version="1.0.0"
4+
LABEL repository="https://github.com/SamKirkland/FTP-Deploy-Action"
5+
LABEL homepage="https://github.com/SamKirkland/FTP-Deploy-Action"
6+
LABEL maintainer="Sam Kirkland <[email protected]>"
7+
8+
LABEL "com.github.actions.name"="FTP Deploy Action"
9+
LABEL "com.github.actions.description"="Deploy your website via FTP"
10+
LABEL "com.github.actions.icon"="upload-cloud"
11+
LABEL "com.github.actions.color"="orange"
12+
13+
RUN apk add lftp
14+
15+
COPY entrypoint.sh /entrypoint.sh
16+
RUN chmod 777 entrypoint.sh
17+
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# FTP Deploy for GitHub Actions
2+
3+
Automate deploying websites and more with this GitHub action.
4+
5+
![Action](images/action.png)
6+
7+
### Usage
8+
```
9+
action "FTP-Deploy-Action" {
10+
uses = "SamKirkland/FTP-Deploy-Action@master"
11+
secrets = ["FTP_USERNAME", "FTP_PASSWORD", "FTP_SERVER"]
12+
}
13+
```
14+
15+
1. Select the repository you want to add the action to
16+
2. Select the actions tab `(currently only for beta testers)`
17+
3. Select `Create a new workflow`
18+
4. Select `Edit new file`
19+
5. Paste the above code into the bottom of the file
20+
6. Go back to the `Visual editor`
21+
7. Click edit on the `FTP-Deploy-Action`
22+
8. In the `secrets` section add the required params
23+
* FTP_USERNAME
24+
* FTP_PASSWORD
25+
* FTP_SERVER
26+
* (see optional settings below)
27+
28+
### Settings
29+
- Options
30+
- __FTP Username__: ${FTP_USERNAME}
31+
- __FTP Password__: ${FTP_PASSWORD}
32+
- __FTP Server__: ${FTP_SERVER}
33+
- __(Optional) Local Dir__: ${LOCAL_DIR}
34+
- __(Optional) Remote Dir__: ${REMOTE_DIR}
35+
- Set actions by editing the action then adding them in the `secrets` section:
36+
- ![Action](images/env.png)
37+
38+
39+
### Explination of steps
40+
- This action is triggered by a `event` on your repo
41+
- A docker image based on `mwienk/docker-lftp` is spun up on github servers
42+
- The docker container compresses your code into a tar.gz file
43+
- The file is then uploaded to the remote server
44+
- The file is then un-zipped
45+
46+
### Debugging locally
47+
###### Instructions for windows
48+
- Install docker for windows
49+
- Open powershell
50+
- Navigate to the repo folder
51+
- Run `docker build --tag action .`
52+
- (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
53+
- Download http://dos2unix.sourceforge.net/
54+
- In another powershell window nagivate to the dos2unix folder /bin
55+
- Run this command every time you modify entrypoint.sh `.\dos2unix.exe "{FULL_PATH_TO_REPO\entrypoint.sh}"`
56+
- Run `docker run action`
57+
58+
###### Instructions for linux
59+
- Please submit a PR for linux instructions :)
60+
61+
62+
### ToDo
63+
- More config options
64+
- Deploy Mode: ${DEPLOY_MODE} `full`|`diffs`
65+
- SSH support
66+
- Switch from lftp to git
67+
68+
Pull Requests Welcome!
69+
70+
### License
71+
----
72+
73+
MIT

entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# "to avoid continuing when errors or undefined variables are present"
4+
set -eu
5+
6+
echo "Starting FTP Deploy"
7+
echo "Uploading files..."
8+
9+
WDEFAULT_LOCAL_DIR=${LOCAL_DIR:-"."}
10+
WDEFAULT_REMOTE_DIR=${REMOTE_DIR:-"."}
11+
12+
lftp $FTP_SERVER -u $FTP_USERNAME,$FTP_PASSWORD -e "set ftp:ssl-allow no; mirror -R $WDEFAULT_LOCAL_DIR $WDEFAULT_REMOTE_DIR; quit"
13+
14+
echo "FTP Deploy Complete"
15+
exit 0

images/action.png

14.7 KB
Loading

images/env.png

17.4 KB
Loading

0 commit comments

Comments
 (0)