如何将 Jekyll 站点从 github 存储库部署到我的 ftp?

How can I deploy Jekyll site from github repo to my ftp?

我有一个自定义的 Jekyll 站点,它在本地运行良好。

我想将我构建的站点部署到我的托管环境中。通过 FTP 和 github 操作可以正常工作:https://github.com/SamKirkland/FTP-Deploy-Action

这是 FTP 工作流程:

on: push
name: Publish Website
jobs:
  FTP-Deploy-Action:
    name: FTP-Deploy-Action
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2.1.0
      with:
        fetch-depth: 2
    - name: FTP-Deploy-Action
      uses: SamKirkland/FTP-Deploy-Action@3.1.1
      with:
        ftp-server: ${{ secrets.FTP_HOST }}
        ftp-username: ${{ secrets.FTP_USER }}
        ftp-password: ${{ secrets.FTP_PASSWORD }}
        local-dir: _site
        git-ftp-args: --changed-only

我尝试使用 _site 文件夹,当不忽略 _site 时,每次提交的操作都是 运行。

所以最好,如果我不提交 _site 页面,那将执行 GitHub 服务器。我找到了这个动作:https://github.com/marketplace/actions/jekyll-actions

我的测试流程:

on: push
name: Testing the GitHub Pages building
    
jobs:
  jekyll:
    runs-on: ubuntu-16.04
    steps:
    - uses: actions/checkout@v2

    # Use GitHub Actions' cache to shorten build times and decrease load on servers
    - uses: actions/cache@v1
      with:
        path: vendor/bundle
        key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
        restore-keys: |
          ${{ runner.os }}-gems-

    # Standard usage
    - uses:  humarci/jekyll-action@1.0.0
    
    # FTP maybe from here

这是我目前使用的,是从The World According to Mike Blog.

中找到的

这使用 ncftp 允许您通过 ftp 轻松上传文件。

name: Build & Upload Site
# Run on pushes to the master branch
on: 
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-ruby@v1
      with:
        ruby-version: '2.7'
    # Install the gems in the gemfile & install ncftp
    - name: Setup Environment.
      run: |
        bundle install
        sudo apt-get install -y ncftp
    
    # Build the site
    - name: Build Site with Jekyll.
      run: JEKYLL_ENV=production bundle exec jekyll build
    
    # Looks kind of complicated but just uploads the content of _site folder to the ftp server. It does not upload the _site folder itself.
    - name: Upload site to FTP.
      env: 
        ftp_location: ${{ secrets.FTP_LOCATION }} # Pass in required secrets.
        ftp_username: ${{ secrets.FTP_USERNAME }}
        ftp_password: ${{ secrets.FTP_PASSWORD }} 
      run: |
        ncftpput -R -v -u "$ftp_username" -p "$ftp_password" $ftp_location / _site/*