⚠️ This is a beta branch, use at your own risk
Automate deploying websites and more with this GitHub action
Usage Example
Place the following in /.github/workflows/main.yml
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v2.3.2
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@beta-v4
      with:
        server: ftp.samkirkland.com
        username: myFtpUserName
        password: ${{ secrets.ftp_password }}
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
Setup Steps
- Select the repository you want to add the action to
- Select the Actionstab
- Select Blank workflow fileorSet up a workflow yourself, if you don't see these options manually create a yaml fileYour_Project/.github/workflows/main.yml
- Paste the example above into your yaml file and save
- Now you need to add a key to the secretssection in your project. To add asecretgo to theSettingstab in your project then selectSecrets. Add a newSecretforpassword
- Update your yaml file settings
Settings
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.
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 | Path and name of the state file - this file is used to track which files have been deployed | 
| dry-run | No | true | false | Prints which modifications will be made with current config options, but doesn't actually make any changes | 
| dangerous-clean-slate | No | true | false | Deletes ALL contents of server-dir, even items in excluded with 'exclude' argument | 
| include | No | `` | ⚠️ not implemented yet - 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/**/* | 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 | 
| security | No | strict | loose | strict: Reject any connection which is not authorized with the list of supplied CAs.loose: Allow connection even when the domain is not certificate | 
Common Examples
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.
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v2.3.2
    - name: Use Node.js 12
      uses: actions/setup-node@v2-beta
      with:
        node-version: '12'
      
    - name: 🔨 Build Project
      run: |
        npm install
        npm run build
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@beta-v4
      with:
        server: ftp.samkirkland.com
        username: myFtpUserName
        password: ${{ secrets.password }}
FTPS
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v2.3.2
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@beta-v4
      with:
        server: ftp.samkirkland.com
        username: myFtpUserName
        password: ${{ secrets.password }}
        protocol: ftps
        port: 1234 # todo replace with your web hosts ftps port
Log only dry run: Use this mode for testing
Ouputs a list of files that will be created/modified to sync your source without making any actual changes
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v2.3.2
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@beta-v4
      with:
        server: ftp.samkirkland.com
        username: myFtpUserName
        password: ${{ secrets.password }}
        dry-run: true
Want another example? Let me know by creating a github issue
FAQ
How to exclude .git files from the publish
todo
How to exclude a specific file or folder
todo
How do I set a upload timeout?
github has a built-in timeout-minutes option, see customized example below
on: push
name: Publish Website
jobs:
  web-deploy:
    name: web-deploy
    runs-on: ubuntu-latest
    timeout-minutes: 15 # time out after 15 minutes (default is 360 minutes)
    steps:
      ....
Debugging locally
- Install the npm package using npm install --dev-only @samkirkland/ftp-deploy
- Add a new key to your package.jsonfile underscripts
- You can run the script using the following command npm run deploy(run this in the folder that has thepackage.jsonfile)
Example of package.json:
{
  "scripts": {
    "deploy": "ftp-deploy --server ftp.samkirkland.com --username test@samkirkland.com --password \"CrazyUniquePassword&%123\"",
  },
}
