A caching website uploader using FTPS
This is a tool to deploy web sites using FTPS.
This assumes that you have already a GitHub Actions workflow that builds and tests your project.
git submodule add https://github.com/oefe/ftpsync.gitAlso, make sure that your workflow checks out submodules:
- name: Checkoutuses: actions/checkout@v2with:
submodules: trueOn GitHub, go to your repository, "Settings", "Secrets". Click "New Secret", enter:
- Name: FTP_PASSWORD
- Value: your FTP password
And click "Add Secret"
Add a deployment step to your GitHub Actions workflow that builds your site:
- name: Deployrun: ftpsync/ftpsync.py example.com --user myself --password "${{ secrets.FTP_PASSWORD }}"This should come after the build and tests steps.
Replace "example.com" with the hostname of your FTP server.
Replace "myself" with your FTP username.
Depending on your build process, you may also have to specify the source directory using the
--sourceoption. The default ("public") is suitable for the Hugo static site generator.Depending on your hosting provider, you may also have to specify the destination directory using the
--destinationoption. The default is "html".
When you are ready, commit and push your changes.
git commit -a -m "Add deployment via ftpsync"Your GitHub Actions workflow should now deploy your site automatically.
The first deployment may take a while, as ftpsync has to upload the entire site. Future deployments should be much faster,
as ftpsync will upload only new and changed files.
This is a complete example how to build and deploy using Hugo and ftpsync.
name: Buildon:
push:
branches: [ master ]jobs:
build:
runs-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v2with:
submodules: truefetch-depth: 0
- name: Setup Hugouses: peaceiris/actions-hugo@v2with:
hugo-version: '0.74.2'
- name: Buildrun: hugo --minifyenv:
HUGO_ENV: production
- name: Deployrun: ftpsync/ftpsync.py example.cpm --user myself --password "${{ secrets.FTP_PASSWORD }}"