2020-02-18 00:34:10 -06:00
<p align="center">
2020-08-26 01:28:40 -05:00
<img alt="FTP Deploy Action - Continuous integration for everyone" src="images/ftp-deploy-logo-small.png">
2020-02-18 00:34:10 -06:00
</p>
2019-01-05 00:48:18 -06:00
2020-08-26 01:28:40 -05:00
> :warning: **This is a beta branch, use at your own risk**
2020-02-18 00:34:10 -06:00
Automate deploying websites and more with this GitHub action
2019-01-05 00:48:18 -06:00
2020-08-26 01:28:40 -05:00


2020-02-18 00:34:10 -06:00
2020-05-02 00:24:55 -05:00
---
### Usage Example
2020-08-26 01:28:40 -05:00
Place the following in `/.github/workflows/main.yml`
2019-09-18 17:28:39 +04:00
```yml
2019-08-29 00:21:07 -05:00
on : push
name : Publish Website
jobs :
2020-08-26 01:28:40 -05:00
web-deploy :
name : 🚀 Deploy website every commit
2019-08-29 00:21:07 -05:00
runs-on : ubuntu-latest
steps :
2020-08-26 01:28:40 -05:00
- name : 🚚 Get latest code
uses : actions/checkout@v2.3.2
- name : 📂 Sync files
2020-08-26 01:40:07 -05:00
uses : SamKirkland/FTP-Deploy-Action@beta-v4
2020-02-18 00:34:10 -06:00
with :
2020-08-26 01:28:40 -05:00
server : ftp.samkirkland.com
username : myFtpUserName
password : ${{ secrets.ftp_password }}
2019-01-05 00:48:18 -06:00
```
2020-05-02 00:24:55 -05:00
---
2020-08-26 01:28:40 -05:00
### Requirements
- You must have ftp access to your server. If your host requires ssh please use my web-deploy action
- Some web hosts change the default port (21), check with your host for your port number
2020-05-02 00:24:55 -05:00
2020-08-26 01:28:40 -05:00
---
### Setup Steps
2019-01-05 00:48:18 -06:00
1. Select the repository you want to add the action to
2020-02-18 00:34:10 -06:00
2. Select the `Actions` tab
2019-08-31 17:11:09 -05:00
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`
2020-02-18 00:34:10 -06:00
4. Paste the example above into your yaml file and save
2020-08-26 01:28:40 -05:00
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 `password`
2020-02-18 00:34:10 -06:00
6. Update your yaml file settings
2019-01-05 00:48:18 -06:00
2020-05-02 00:24:55 -05:00
---
2019-01-05 00:48:18 -06:00
### Settings
2019-10-08 00:26:19 -05:00
Keys can be added directly to your .yml config file or referenced from your project `Secrets` storage.
To add a `secret` go to the `Settings` tab in your project then select `Secrets` .
2020-08-26 01:28:40 -05:00
I strongly recommend you store your `password` as a secret.
| Key Name | Required | Example | Default Value | Description |
|-------------------------|----------|----------------------------|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `server` | Yes | `ftp.samkirkland.com` | | Deployment destination server |
| `username` | Yes | `username@samkirkland.com` | | FTP user name |
| `password` | Yes | `CrazyUniquePassword&%123` | | FTP password, be sure to escape quotes and spaces |
| `port` | No | `990` | `21` | Server port to connect to (read your web hosts docs) |
| `protocol` | No | `ftps` | `ftp` | ftp: provides no encryption, ftps: full encryption newest standard (aka "explicit" ftps), ftps-legacy: full encryption legacy standard (aka "implicit" ftps) |
| `local-dir` | No | `./myFolderToPublish/` | `./` | Path to upload to on the server, must end with trailing slash `/` |
| `server-dir` | No | `public_html/www/` | `./` | Folder to upload from, must end with trailing slash `/` |
| `state-name` | No | `folder/.sync-state.json` | `.ftp-deploy-sync-state.json` | Custom |
| `dry-run` | No | `true` | `false` | :warning: todo - Prints which modifications will be made with current config options, but doesn't actually make any changes |
| `dangerous-clean-slate` | No | `true` | `false` | :warning: todo - Deletes ALL contents of server-dir, even items in excluded with 'exclude' argument |
| `include` | No | | `` | :warning: todo - An array of glob patterns, these files will always be included in the publish/delete process - even if no change occurred |
| ` exclude` | No | | ` .git*` ` .git*/**` ` node_modules/**` ` node_modules/**/*` | :warning: todo - An array of glob patterns, these files will not be included in the publish/delete process |
| ` log-level` | No | ` info` | ` info` | ` warn`: only important/warning info, ` info`: default, log important/warning info & progress info, ` debug`: log everything for debugging |
2020-02-18 00:34:10 -06:00
2020-05-02 00:24:55 -05:00
# Common Examples
2020-08-26 01:28:40 -05:00
#### Build and Publish React/Angular/Vue Website
Make sure you have an npm script named 'build'. This config should work for most node built websites.
2020-02-18 00:34:10 -06:00
2019-09-18 17:28:39 +04:00
` ``yml
2019-09-15 23:56:38 -05:00
on: push
2020-02-18 00:34:10 -06:00
name: Publish Website
2019-09-15 23:56:38 -05:00
jobs:
2020-08-26 01:28:40 -05:00
web-deploy:
name: 🚀 Deploy website every commit
2019-09-15 23:56:38 -05:00
runs-on: ubuntu-latest
steps:
2020-08-26 01:28:40 -05:00
- name: 🚚 Get latest code
uses: actions/checkout@v2.3.2
2020-02-18 00:34:10 -06:00
2020-08-26 01:28:40 -05:00
- name: Use Node.js 12
uses: actions/setup-node@v2-beta
2020-02-18 00:34:10 -06:00
with:
2020-08-26 01:28:40 -05:00
node-version: '12'
- name: 🔨 Build Project
run: |
npm install
npm run build
- name: 📂 Sync files
2020-08-26 01:40:07 -05:00
uses: SamKirkland/FTP-Deploy-Action@beta-v4
2020-02-18 00:34:10 -06:00
with:
2020-08-26 01:28:40 -05:00
server: ftp.samkirkland.com
username: myFtpUserName
password: ${{ secrets.password }}
2020-02-18 00:34:10 -06:00
` ``
2020-08-26 01:28:40 -05:00
#### FTPS
2020-02-18 00:34:10 -06:00
` ``yml
on: push
2020-08-26 01:28:40 -05:00
name: Publish Website Dry Run
2020-02-18 00:34:10 -06:00
jobs:
2020-08-26 01:28:40 -05:00
web-deploy:
name: 🚀 Deploy website every commit
2020-02-18 00:34:10 -06:00
runs-on: ubuntu-latest
steps:
2020-08-26 01:28:40 -05:00
- name: 🚚 Get latest code
uses: actions/checkout@v2.3.2
2020-02-18 00:34:10 -06:00
2020-08-26 01:28:40 -05:00
- name: 📂 Sync files
2020-08-26 01:40:07 -05:00
uses: SamKirkland/FTP-Deploy-Action@beta-v4
2020-02-18 00:34:10 -06:00
with:
2020-08-26 01:28:40 -05:00
server: ftp.samkirkland.com
username: myFtpUserName
password: ${{ secrets.password }}
protocol: ftps
2019-10-08 00:26:19 -05:00
` ``
2020-08-26 01:28:40 -05:00
#### Log only dry run: Use this mode for testing
2019-09-15 23:56:38 -05:00
Ouputs a list of files that will be created/modified to sync your source without making any actual changes
2019-09-18 17:28:39 +04:00
` ``yml
2019-09-15 23:56:38 -05:00
on: push
name: Publish Website Dry Run
jobs:
2020-08-26 01:28:40 -05:00
web-deploy:
name: 🚀 Deploy website every commit
2019-09-15 23:56:38 -05:00
runs-on: ubuntu-latest
steps:
2020-08-26 01:28:40 -05:00
- name: 🚚 Get latest code
uses: actions/checkout@v2.3.2
2020-02-18 00:34:10 -06:00
2020-08-26 01:28:40 -05:00
- name: 📂 Sync files
2020-08-26 01:40:07 -05:00
uses: SamKirkland/FTP-Deploy-Action@beta-v4
2020-02-18 00:34:10 -06:00
with:
2020-08-26 01:28:40 -05:00
server: ftp.samkirkland.com
username: myFtpUserName
password: ${{ secrets.password }}
dry-run: true
2019-09-15 23:56:38 -05:00
` ``
2019-01-05 00:48:18 -06:00
2020-08-26 01:28:40 -05:00
_Want another example? Let me know by creating a [github issue](https://github.com/SamKirkland/FTP-Deploy-Action/issues/new)_
2020-05-02 00:24:55 -05:00
---
2019-01-05 00:48:18 -06:00
2019-09-16 00:55:22 -05:00
## FAQ
2020-05-02 00:24:55 -05:00
<details>
<summary>How to exclude .git files from the publish</summary>
2020-08-26 01:28:40 -05:00
todo
2020-05-02 00:24:55 -05:00
</details>
<details>
2020-08-26 01:28:40 -05:00
<summary>How to exclude a specific file or folder</summary>
2020-05-02 00:24:55 -05:00
2020-08-26 01:28:40 -05:00
todo
2020-05-02 00:24:55 -05:00
</details>
2020-08-26 01:28:40 -05:00
2020-05-02 00:24:55 -05:00
<details>
<summary>How do I set a upload timeout?</summary>
github has a built-in ` timeout-minutes` option, see customized example below
` ``yaml
on: push
name: Publish Website
jobs:
2020-08-26 01:28:40 -05:00
web-deploy:
name: web-deploy
2020-05-02 00:24:55 -05:00
runs-on: ubuntu-latest
timeout-minutes: 15 # time out after 15 minutes (default is 360 minutes)
steps:
....
` ``
</details>
## Debugging locally
2020-08-26 01:28:40 -05:00
- Install the npm package using ` npm install --dev-only @samkirkland/ftp -deploy`
- Add a new key to your ` package.json` file under ` scripts`
- You can run the script using the following command ` npm run deploy` (run this in the folder that has the ` package.json` file)
Example of ` package.json`:
` ``json
{
"scripts": {
"deploy": "ftp-deploy --server ftp.samkirkland.com --username test@samkirkland.com --password \"CrazyUniquePassword&%123\"",
},
}
2020-08-26 01:40:07 -05:00
` ``