Jekyll & Wercker - 如何部署子目录

Jekyll & Wercker - How to deploy a subdirectory

问题: 我在通过 Wercker 将 Jekyll 构建文件夹部署到 FTP 服务器时遇到困难。

我一直在使用 Wercker 来持续集成我正在处理的 Jekyll 站点。使用下面的脚本,构建过程:jekyll buildjekyll doctor 似乎按预期工作。

我的部署步骤应该将“_site”文件夹上传到我的 FTP 服务器。我目前正在使用 duleorlovic 的 ftp-deploy wercker 步骤。它当前正在上传整个目录,而不仅仅是构建文件夹。

但是,Jekyll 使用/_site 文件夹作为站点构建的目录......我怎么能限制我的上传到 /_site 建立文件夹?

谢谢。

当前wercker.yml如下:

# Wercker Configuration
# continuous delivery platform that helps software developers 
# build and deploy their applications and microservices

box: ruby
build:
  steps:

    # Install dependencies
    - bundle-install

    # Execute jeykyll doctor command to validate the
    # site against a list of known issues.
    - script:
        name: jekyll doctor
        code: bundle exec jekyll doctor

    - script:
        name: jekyll build
        code: bundle exec jekyll build --trace

deploy:
  steps:
    - duleorlovic/ftp-deploy:
        destination: $FTP_SERVER
        username: $FTP_USERNAME
        password: $FTP_PASSWORD
        timeout: 15
        remote-file: remote.txt

问题解决了。

显然 Worker 提供了一个名为 $WERCKER_OUTPUT_DIR 的环境变量。此目录是在构建步骤通过时通过管道传输到部署步骤的文件夹。如果没有传递任何东西,部署步骤只使用根目录(也就是 而不是 你的构建文件夹)。

工作 wercker.yml 包含 jekyll build 步骤如下:

   - script:
       name: jekyll build
       code: bundle exec jekyll build --trace --destination "$WERCKER_OUTPUT_DIR"

我没能在 Wercker 文档中找到很多关于这个问题的信息,因为它似乎在版本之间转换,但我在如何使用 wercker 的示例中找到了解决方案。

您可以在他们的指南中查看使用输出目录的示例 How Wercker Works.

通过将 cwd: 参数传递给步骤,您可以更改工作目录(根据 wercker doc):

deploy:
  steps:
  - duleorlovic/ftp-deploy:
      cwd: _site/
      destination: $FTP_SERVER
      username: $FTP_USERNAME
      password: $FTP_PASSWORD
      timeout: 15
      remote-file: remote.txt