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.git
Also, make sure that your workflow checks out submodules:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
On 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: Deploy
run: 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
--source
option. 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
--destination
option. 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.
THhe first deployment may take a while, as ftpsync
has to upload the entire site. Futhre 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: Build
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.74.2'
- name: Build
run: hugo --minify
env:
HUGO_ENV: production
- name: Deploy
run: ftpsync/ftpsync.py example.cpm --user myself --password "${{ secrets.FTP_PASSWORD }}"