Skip to content

Commit 90efcaa

Browse files
committed
web-deploy
1 parent 977f32e commit 90efcaa

File tree

15 files changed

+2335
-1
lines changed

15 files changed

+2335
-1
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Bug Description**
11+
A clear and concise description of what the bug is.
12+
13+
**My Action Config**
14+
```yaml
15+
on:
16+
push:
17+
# !!!!!!! TODO Fill Out !!!!!!!
18+
```
19+
20+
**My Action Log**
21+
```
22+
# Paste Log here
23+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on: push
2+
name: Test FTP Deploy
3+
jobs:
4+
FTP-Deploy-Action:
5+
name: FTP-Deploy-Action
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2.1.0
9+
- name: FTP-Deploy-Action
10+
uses: SamKirkland/FTP-Deploy-Action@master
11+
with:
12+
target-server: samkirkland.com
13+
destination-path: rsync-deploy-action.samkirkland.com/
14+
remote-user: ${{ secrets.user }}
15+
remote-key: ${{ secrets.pass }}

.gitignore

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
__tests__/runner/*
2+
3+
# comment out in distribution branches
4+
node_modules/
5+
6+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
7+
# Logs
8+
logs
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
15+
# Diagnostic reports (https://nodejs.org/api/report.html)
16+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17+
18+
# Runtime data
19+
pids
20+
*.pid
21+
*.seed
22+
*.pid.lock
23+
24+
# Directory for instrumented libs generated by jscoverage/JSCover
25+
lib-cov
26+
27+
# Coverage directory used by tools like istanbul
28+
coverage
29+
*.lcov
30+
31+
# nyc test coverage
32+
.nyc_output
33+
34+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35+
.grunt
36+
37+
# Bower dependency directory (https://bower.io/)
38+
bower_components
39+
40+
# node-waf configuration
41+
.lock-wscript
42+
43+
# Compiled binary addons (https://nodejs.org/api/addons.html)
44+
build/Release
45+
46+
# Dependency directories
47+
jspm_packages/
48+
49+
# TypeScript v1 declaration files
50+
typings/
51+
52+
# TypeScript cache
53+
*.tsbuildinfo
54+
55+
# Optional npm cache directory
56+
.npm
57+
58+
# Optional eslint cache
59+
.eslintcache
60+
61+
# Optional REPL history
62+
.node_repl_history
63+
64+
# Output of 'npm pack'
65+
*.tgz
66+
67+
# Yarn Integrity file
68+
.yarn-integrity
69+
70+
# dotenv environment variables file
71+
.env
72+
.env.test
73+
74+
# parcel-bundler cache (https://parceljs.org/)
75+
.cache
76+
77+
# next.js build output
78+
.next
79+
80+
# nuxt.js build output
81+
.nuxt
82+
83+
# vuepress build output
84+
.vuepress/dist
85+
86+
# Serverless directories
87+
.serverless/
88+
89+
# FuseBox cache
90+
.fusebox/
91+
92+
# DynamoDB Local files
93+
.dynamodb/

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.exclude": {
3+
"**/node_modules": true
4+
}
5+
}

README.md

Lines changed: 207 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,207 @@
1-
# rsync-Deploy-Action
1+
<p align="center">
2+
<img alt="web deploy - Continuous integration for everyone" src="images/web-deploy-logo-small.png">
3+
</p>
4+
5+
Automate deploying websites and more with this GitHub action
6+
7+
![Test web deploy](https://github.com/SamKirkland/web-deploy/workflows/Test%20web%20deploy/badge.svg)
8+
9+
---
10+
11+
### Usage Example
12+
Place the following in `Your_Project/.github/workflows/main.yml`
13+
```yml
14+
on: push
15+
name: Publish Website
16+
jobs:
17+
web-deploy:
18+
name: 🚀 Deploy website every commit
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: 🚚 Get latest code
22+
uses: actions/checkout@v2.1.0
23+
24+
- name: 📂 Sync files
25+
uses: SamKirkland/web-deploy@1.0.0
26+
with:
27+
target-server: samkirkland.com
28+
remote-user: myFtpUserName
29+
remote-key: ${{ secrets.SSH_KEY }}
30+
```
31+
32+
---
33+
34+
### Requirements
35+
- You must have shell access to your server, please read you webite hosts documentation
36+
- **You CANNOT use a FTP account - they are not the same!**
37+
- If you don't have SSH access but have ftp access use [FTP-Deploy-Action](https://github.com/SamKirkland/FTP-Deploy-Action) instead
38+
- You will need to create a **SSH** user to deploy. Normally this is your cpanel or hosting providers username and password
39+
- Most web hosts change the default port (22), check with your host for your port number
40+
41+
---
42+
43+
### Setup Steps
44+
1. Select the repository you want to add the action to
45+
2. Select the `Actions` tab
46+
3. Select `Blank workflow file` or `Set up a workflow yourself`, if you don't see these options manually create a yaml file `Your_Project/.github/workflows/main.yml`
47+
4. Paste the example above into your yaml file and save
48+
5. Now you need to add a key to the `secrets` section in your project. To add a `secret` go to the `Settings` tab in your project then select `Secrets`. Add a new `Secret` for `ftp-password`
49+
6. Update your yaml file settings
50+
51+
---
52+
53+
### Settings
54+
Keys can be added directly to your .yml config file or referenced from your project `Secrets` storage.
55+
56+
To add a `secret` go to the `Settings` tab in your project then select `Secrets`.
57+
I strongly recommend you store your `remote-key` as a secret.
58+
59+
| Key Name | Required? | Example | Default | Description |
60+
|--------------------|-----------|-----------------------------------|---------|----------------------------------------------------------|
61+
| `target-server` | Yes | `ftp.samkirkland.com` | | Deployment destination server. Formatted as `domain.com:port`. Port is optional, when not specified it will default to 22 |
62+
| `remote-user` | Yes | `username@samkirkland.com` | | SSH user name |
63+
| `remote-key` | Yes | `CrazyUniquePassword&%123` | | SSH private key |
64+
| `source-path` | No | `./myFolderToPublish/` | `./` | Path to upload to on the server, must end with trailing slash `/` |
65+
| `destination-path` | No | `ftp.samkirkland.com` | `./` | Folder to upload from, must end with trailing slash `/` |
66+
| `rsync-options` | No | See `rsync-options` section below | `--archive --verbose --compress --human-readable --delete --exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude .gitignore` | Custom rsync arguments, this field is passed through directly into the rsync script |
67+
68+
#### Advanced options using `rsync-options`
69+
Custom arguments, this field is passed through directly into the rsync script. See [rsync's manual](https://linux.die.net/man/1/rsync) for all options.
70+
You can use as many arguments as you want, seperate them with a space
71+
72+
Below is an incomplete list of commonly used args:
73+
74+
| Option | Description |
75+
|------------------------|------------------------------------------------------------------------------------------------------------------|
76+
| `--dry-run` | Does not upload or delete anything, but tells you what it would upload/delete if this was a real deploy |
77+
| `--stats` | Print verbose statistics on the file transfer, allowing you to tell how effective rsync’s delta-transfer algorithm is for your data |
78+
| `--links` | When symlinks are encountered, recreate the symlink on the destination |
79+
| `--compress` | Compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted |
80+
| `--human-readable` | Output bytes in a more human-readable format (K, M, G) |
81+
| `--delete` | When you delete a file on github it will also be deleted on the server |
82+
| `--max-size '200K'` | Ignore syncing files over this limit. Value is a number followed by "K", "M", or "G" |
83+
| `--exclude 'file.txt'` | Excludes file(s) from the deployment. Supports glob pattterns (ex: `*.jpg`). You can have multiple excludes! |
84+
| `--include 'file.txt'` | Includes file(s) even if it was excluded. Supports glob pattterns (ex: `*.jpg`). You can have multiple includes! |
85+
86+
87+
# Common Examples
88+
#### Build and Publish React/Angular/Vue Website
89+
Make sure you have an npm script named 'build'. This config should work for most node built websites.
90+
91+
```yml
92+
on: push
93+
name: Publish Website
94+
jobs:
95+
web-deploy:
96+
name: 🚀 Deploy website every commit
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: 🚚 Get latest code
100+
uses: actions/checkout@v2.1.0
101+
102+
- name: Use Node.js 12.x
103+
uses: actions/setup-node@v1
104+
with:
105+
node-version: '12.x'
106+
107+
- name: 🔨 Build Project
108+
run: |
109+
npm install
110+
npm run build
111+
112+
- name: 📂 Sync files
113+
uses: SamKirkland/web-deploy@1.0.0
114+
with:
115+
target-server: samkirkland.com
116+
remote-user: myFtpUserName
117+
remote-key: ${{ secrets.SSH_KEY }}
118+
```
119+
120+
#### Log only dry run: Use this mode for testing
121+
Ouputs a list of files that will be created/modified to sync your source without making any actual changes
122+
```yml
123+
on: push
124+
name: Publish Website Dry Run
125+
jobs:
126+
web-deploy:
127+
name: 🚀 Deploy website every commit
128+
runs-on: ubuntu-latest
129+
steps:
130+
- name: 🚚 Get latest code
131+
uses: actions/checkout@v2.1.0
132+
133+
- name: 📂 Sync files
134+
uses: SamKirkland/web-deploy@1.0.0
135+
with:
136+
ftp-server: samkirkland.com
137+
ftp-username: myFTPUsername
138+
ftp-password: ${{ secrets.FTP_PASSWORD }}
139+
git-ftp-args: --dry-run
140+
```
141+
142+
_Want another example? Let me know by creating a [github issue](https://github.com/SamKirkland/web-deploy/issues/new)_
143+
144+
---
145+
146+
## FAQ
147+
<details>
148+
<summary>How to exclude .git files from the publish</summary>
149+
150+
Git files are excluded by default
151+
152+
If have customized `rsync-options` you will need to re-add the default exclude options using `--exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude=.gitignore`
153+
</details>
154+
155+
<details>
156+
<summary>How to exclude a specific file or folder</summary>
157+
158+
You can use `rsync-options` and pass in as many `--exclude` options as you want. By default this action excludes github files. If you choose to customize `rsync-options` make sure you copy over the defaults.
159+
160+
161+
Example excluding all `.jpg` files:
162+
163+
`rsync-options: --exclude "*.jpg"`
164+
165+
166+
Example excluding a specific folder:
167+
168+
`rsync-options: --exclude "wp-content/themes/"`
169+
</details>
170+
171+
172+
<details>
173+
<summary>How do I set a upload timeout?</summary>
174+
175+
github has a built-in `timeout-minutes` option, see customized example below
176+
177+
```yaml
178+
on: push
179+
name: Publish Website
180+
jobs:
181+
web-deploy:
182+
name: web-deploy
183+
runs-on: ubuntu-latest
184+
timeout-minutes: 15 # time out after 15 minutes (default is 360 minutes)
185+
steps:
186+
....
187+
```
188+
</details>
189+
190+
---
191+
192+
## Common Errors
193+
<details id="ssl-peer-certificate">
194+
<summary>Error: SSL peer certificate or SSH remote key was not OK</summary>
195+
196+
Whitelist your host via the `known-hosts` configuration option or add the `--insecure` argument
197+
</details>
198+
199+
---
200+
201+
## Debugging locally
202+
##### Instructions for debugging on windows
203+
- Install docker for windows
204+
- Open powershell
205+
- Navigate to the repo folder
206+
- Run `docker build --tag action .`
207+
- Run `docker run action`

action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'web deploy'
2+
description: 'Deploy websites via sftp/ssh'
3+
author: 'Sam Kirkland'
4+
inputs:
5+
target-server:
6+
description: 'eployment destination server. Formatted as domain.com:port. Port is optional, when not specified it will default to 22'
7+
required: true
8+
remote-user:
9+
description: 'SSH account username'
10+
required: true
11+
remote-key:
12+
description: 'SSH account password'
13+
required: true
14+
source-path:
15+
description: 'Path to upload to on the server, must end with trailing slash /'
16+
required: true
17+
destination-path:
18+
description: 'Folder to upload from, must end with trailing slash /'
19+
required: true
20+
rsync-options:
21+
description: 'Passes through options into rsync'
22+
default:
23+
required: false
24+
runs:
25+
using: 'node12'
26+
image: 'dist/index.js'
27+
branding:
28+
icon: 'upload-cloud'
29+
color: 'blue'

0 commit comments

Comments
 (0)