CI/CD with GitHub Actions and FTP: a practical guide
Automate building and publishing a static site on every push to the main branch, using GitHub secrets for the FTP credentials.
Uploading files by hand over FTP is slow and error-prone. With GitHub Actions we can make deployment fully automatic.
The secrets
In the repository go to Settings → Secrets and variables → Actions and create:
| Secret | Example |
|---|---|
FTP_SERVER | ftp.mydomain.com |
FTP_USERNAME | user@mydomain.com |
FTP_PASSWORD | •••••••• |
The workflow
The flow is simple: checkout, installing dependencies with npm ci, build, and syncing the build/ folder.
- name: Deploy via FTP
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./build/The action keeps a state file on the server and uploads only the files that changed, making subsequent deployments very fast.