-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Publishing from a GitHub repository to a web server via FTP or FTPS can be automated using GitHub Actions. Here’s a step-by-step guide to help you set it up:
-
Create a GitHub Repository:
- If you don't already have a repository, create one on GitHub.
-
Set Up Your FTP Server:
- Ensure you have access to an FTP server. You'll need the server address, username, password, and the path where you want to deploy your files.
-
Add Secrets to Your GitHub Repository:
- Go to your repository on GitHub.
- Navigate to Settings > Secrets and variables > Actions.
- Add the following secrets:
FTP_SERVER: Your FTP server address.FTP_USERNAME: Your FTP username.FTP_PASSWORD: Your FTP password.
-
Create a GitHub Actions Workflow:
- In your repository, create a directory named
.github/workflows. - Inside this directory, create a file named
deploy.ymlwith the following content:
- In your repository, create a directory named
name: 🚀 Deploy website on push
on:
push:
branches:
- main # Change this to your default branch
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout repository
uses: actions/checkout@v4
- name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
protocol: ftps # Change to 'ftp' if you are not using FTPS
local-dir: ./ # Directory to upload from
server-dir: /public_html/ # Directory to upload to on the server-
Commit and Push Your Changes:
- Commit the
deploy.ymlfile to your repository and push the changes to GitHub.
- Commit the
-
Automatic Deployment:
- Now, every time you push changes to the
mainbranch (or the branch you specified), GitHub Actions will automatically deploy your files to the FTP server.
- Now, every time you push changes to the
This setup uses the SamKirkland/FTP-Deploy-Action GitHub Action, which simplifies the process of deploying files via FTP or FTPS¹(https://github.com/marketplace/actions/ftp-deploy)²(https://www.inmotionhosting.com/support/website/git/deploy-files-github-actions/).
Would you like more details on any of these steps?
Kilde: Samtale med Copilot, 20.1.2025
(1) FTP Deploy · Actions · GitHub Marketplace · GitHub. https://github.com/marketplace/actions/ftp-deploy.
(2) Deploy Files With GitHub Actions for FTP and SCP - InMotion Hosting. https://www.inmotionhosting.com/support/website/git/deploy-files-github-actions/.