Sha256: ae1264c7f5b8c54939a31989c1924c7bdc0e94ce59c84db1ff8110a425b95d4b
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require 'awestruct/deploy/base_deploy' require 'git' module Awestruct module Deploy class GitHubPagesDeploy < Base def initialize(site_config, deploy_config) super @branch = deploy_config['branch'] || 'gh-pages' @repo = deploy_config['repository'] || 'origin' end def publish_site tmp_branch = '__awestruct_deploy__' detached_branch = nil original_branch = git.current_branch # detect a detached state # values include (no branch), (detached from x), etc if original_branch.start_with? '(' detached_branch = git.log(1).first.sha git.branch(original_branch = tmp_branch).checkout end # work in a branch, then revert to current branch git.branch(@branch).checkout add_and_commit_site @site_path git.push(@repo, @branch) if detached_branch git.checkout detached_branch git.branch(original_branch).delete else git.checkout original_branch end end private def add_and_commit_site(path) git.with_working(path) do git.add(".") begin git.commit("Published #{@branch} to GitHub pages.") rescue ::Git::GitExecuteError => e $LOG.error "Can't commit. #{e}." if $LOG.error? end end git.reset_hard end def git @git ||= ::Git.open('.') end end end end Awestruct::Deployers.instance[:github_pages] = Awestruct::Deploy::GitHubPagesDeploy
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
awestruct-0.5.4.rc | lib/awestruct/deploy/github_pages_deploy.rb |