Skip to content

GitHub -> FTP #8

@rockphotog

Description

@rockphotog

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:

  1. Create a GitHub Repository:

    • If you don't already have a repository, create one on GitHub.
  2. 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.
  3. 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.
  4. Create a GitHub Actions Workflow:

    • In your repository, create a directory named .github/workflows.
    • Inside this directory, create a file named deploy.yml with the following content:
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
  1. Commit and Push Your Changes:

    • Commit the deploy.yml file to your repository and push the changes to GitHub.
  2. Automatic Deployment:

    • Now, every time you push changes to the main branch (or the branch you specified), GitHub Actions will automatically deploy your files to the FTP server.

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/.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions