Class: Awestruct::Deploy::GitHubPagesDeploy

Inherits:
Base
  • Object
show all
Defined in:
lib/awestruct/deploy/github_pages_deploy.rb

Constant Summary

Constants inherited from Base

Base::UNCOMMITTED_CHANGES

Instance Method Summary collapse

Methods inherited from Base

#existing_changes, #git, #run

Constructor Details

#initialize(site_config, deploy_config) ⇒ GitHubPagesDeploy

Returns a new instance of GitHubPagesDeploy.



6
7
8
9
10
# File 'lib/awestruct/deploy/github_pages_deploy.rb', line 6

def initialize( site_config, deploy_config )
  @site_path = site_config.output_dir
  @branch    = deploy_config[ 'branch' ] || 'gh-pages'
  @repo      = deploy_config[ 'repository' ] || 'origin'
end

Instance Method Details

#publish_siteObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/awestruct/deploy/github_pages_deploy.rb', line 12

def publish_site
  current_branch = git.current_branch
  # we may be on a detached branch,
  # in which case use that commit as the branch
  if current_branch == '(no branch)'
    current_branch = git.revparse('HEAD')
  end
  git.branch( @branch ).checkout
  add_and_commit_site @site_path
  git.push( @repo, @branch )
  git.checkout( current_branch )
end