Upload only changes to FTP Server
It will check if the remote path has .revision
, will download and compare the hash from that file with the new commit hash, then upload the changes to remote server, and update the .revision
in the remote server. If there is no .revision
it will compare and upload from the initial commit
Required Hostname or ip address ftp server
Port number ftp server. Default 21
Required Username to login ftp server
Password to login ftp server
SSL/TLS options
Root local directory to deploy, default is your root project
Root remote directory ftp server, default is depend your default home user
Ignore files, support glob wildcard, separated by comma each pattern. default: .github/**,.gitignore,**/.gitignore
Remote revision hash
on:
push:
branches: [ master ]
jobs:
deploy_job:
runs-on: ubuntu-latest
name: deploy
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: deploy file
uses: swznd/ftp-deploy@master
with:
host: ftp.example.com
user: username
password: ${{ secrets.FTP_PASSWORD }}
ignore: .github/**
It will fetch and checkout only the changes, the .revision
file need can be accessed via web
name: deploy
on:
push:
branches: [ master ]
env:
TOTAL_COMMITS: "0"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# fetch revision
- id: fetch_revision
name: fetch revision
run: echo ::set-output name=revision::$(curl -m 15 https://example.com/.revision)
# check how much commits ahead via github API
- id: get_total_commit_ahead
name: fetch total commits count
uses: octokit/request-action@v2.x
if: steps.fetch_revision.outputs.revision != ''
with:
route: GET /repos/:repository/compare/:base...:head
repository: ${{ github.repository }}
base: ${{ steps.fetch_revision.outputs.revision }}
head: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: parse_total_commit_ahead
uses: gr2m/get-json-paths-action@v1.x
if: steps.fetch_revision.outputs.revision != ''
with:
json: ${{ steps.get_total_commit_ahead.outputs.data }}
total_commits: "total_commits"
# update TOTAL_COMMIT variable
- name: set total_commit # set total commit to env
if: steps.parse_total_commit_ahead.outputs.total_commits != ''
run: "echo ::set-env name=TOTAL_COMMITS::$(( ${{ steps.parse_total_commit_ahead.outputs.total_commits }} + 1 ))" # add one commit back, so it can compare from remote revision
- uses: actions/checkout@v2
with:
fetch-depth: ${{ env.TOTAL_COMMITS }} # fetch with total commit
- name: upload
uses: swznd/ftp-deploy@master
with:
host: ftp.example.com
user: user
password: ${{ secrets.FTP_ZEOBOT_PASSWORD }}
SFTP Deployment: https://github.com/swznd/sftp-deploy/