middleman-deploy从root而不是build dir推送

时间:2015-12-19 07:14:38

标签: ruby github deployment github-pages middleman

背景

我使用middleman-deploy部署到组织的github页面。

我的理解是,中间人构建dir(在这种情况下为/build)将被部署到github。也就是说,包含bundle exec middleman build之后的文件的目录,包括index.html文件。

我在github回购中获得的是该项目的根本。我正在使用bundle exec middleman deploy --build-before

config.rb

activate :deploy do |deploy| deploy.method = :git deploy.remote = 'https://github.com/FiercePunchStudios/fiercepunchstudios.github.io.git' deploy.branch = 'master' end

问题

如何使用middleman-deploy将我的中间人网站部署到github 组织页面?

1 个答案:

答案 0 :(得分:0)

感谢@robinbortlik,在github问题上有一个方便的小扩展。 https://github.com/middleman-contrib/middleman-deploy/issues/114#issuecomment-168139237

#lib/build_cleaner.rb

class BuildCleaner < Middleman::Extension

  def initialize(app, options_hash={}, &block)
    super
    FileUtils.rm_rf app.config[:build_dir]
  end

end

::Middleman::Extensions.register(:build_cleaner, BuildCleaner)
#config.rb

require_relative "./lib/build_cleaner"

configure :build do
  activate :build_cleaner
end

这会在构建操作之前删除构建目录。现在您只需执行一个命令,例如bundle exec middleman deploy --build-before

我仍然没有考虑修复问题,因为我不想在我开始的每个中间人项目中添加样板。但是,它是一种方便的解决方法,可以平滑部署过程。