Class: Middleman::GhPages::Deploy

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman/gh_pages/deploy.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Deploy

Returns a new instance of Deploy.



4
5
6
7
8
# File 'lib/middleman/gh_pages/deploy.rb', line 4

def initialize(options = {})
  @build_dir = options.fetch(:build_dir)
  @remote = options.fetch(:remote)
  @environment = options.fetch(:environment)
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/middleman/gh_pages/deploy.rb', line 10

def call
  bundle.exec 'middleman', 'build', '-e', @environment

  Dir.chdir(@build_dir) do
    git.init
    git.remote 'add', 'origin', @remote
    git.add '.'
    git.commit '-m', "Deploy on #{Time.now}"
    git.checkout '-b', 'gh-pages'
    git.push '-f', 'origin', 'gh-pages'
  end
end