SFTP/FTP Server Upload w/GitHub Actions
This repository contains a complete, step-by-step guide and workflow configuration to automate deploying your website or files to an FTP server using GitHub Actions.
Automate your deployment process easily and securely!
- Trigger deployment automatically on pushes to a specific branch (e.g.,
main) - Fetch latest code from your repository
- Optionally build your project before deployment
- Upload files securely via FTP or FTPS
- Exclude specific files or folders from deployment
- Use secrets for sensitive credentials
- Supports dry-run mode for testing
- A GitHub repository
- Access to an FTP, FTPS or even SFTP server
- SFTP/FTP credentials (server address, username, password) sftp can just PASSWORD recomended using ssh keys but.. where
- (Optional) Build commands if deploying a static website or app
- GitHub Secrets configured for secure credential storage
- Navigate to your GitHub repository
- Go to Settings > Secrets and variables > Actions > New repository secret
Create the following secrets:
| Secret Name | Description |
|---|---|
FTP_SERVER |
Your FTP server address (e.g., ftp.example.com) |
FTP_USERNAME |
Your FTP username |
FTP_PASSWORD |
Your FTP password |
Important: Never commit sensitive credentials directly into your code.
- In your repo, navigate to
.github/workflows/ - Create a new file, e.g.,
main.ymlnormaen.yml - Paste the provided workflow configuration (see below)
- Adjust
server-dir,local-dir, and other optional parameters as per your project structure - Uncomment build steps if needed
- Enable
protocol: ftpsif your server supports secure transfer
name: Deploy Anything via FTP - Complete Documentary Workflow
on:
push:
branches:
- main # Trigger deployment on pushes to 'main' branch
jobs:
web-deploy:
name: 🎉 Automated FTP Deployment Workflow
runs-on: ubuntu-latest
steps:
- name: 🚚 Get the Latest Code
uses: actions/checkout@v4
# Optional: Configure Node.js environment if building your project
# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: '16'
# Optional: Build your project before deployment
# - name: Build Project
# run: |
# npm install
# npm run build
- name: 📂 Sync Files to FTP Server
uses: SamKirkland/FTP-Deploy-Action@v4.3.6
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
server-dir: ./htdocs/ # Adjust as needed
# protocol: ftps # Uncomment for secure transfer
# dry-run: false # Enable for testing
# exclude: |
# **/.git*
# **/node_modules/**- Dry-Run Mode: Use
dry-run: trueduring testing to see what files would be uploaded without affecting your server. - Excluding Files: Customize the
excludelist to prevent uploading sensitive files or unnecessary data. - Secure Transfer: Use
protocol: ftpsfor encrypted file transfer if your host supports it. - Multiple Environments: Create different workflows or secrets for staging and production deployments.
- Ensure secrets are correctly added and referenced.
- Verify your FTP server details and credentials.
- Check the logs in GitHub Actions for errors or warnings.
- Confirm that your server directory paths are correct and writable.
If you encounter issues or want to contribute enhancements, feel free to open an issue or pull request! u can sponsor us too if u want
This project is open-source and available under the MIT License. github.com/SamKirkland/FTP-Deploy-Action/LICENSE
Automating your FTP deployments with GitHub Actions saves time, reduces errors, and secures your credentials. Customize the workflow to fit your project's needs and enjoy seamless deployment!
Happy deploying! 🚀