class DPL::Provider::Pages
Public Class Methods
new(context, options)
click to toggle source
Calls superclass method
DPL::Provider::new
# File lib/dpl/provider/pages.rb, line 22 def initialize(context, options) super @build_dir = options[:local_dir] || '.' @project_name = options[:project_name] || fqdn || slug @target_branch = options[:target_branch] || 'gh-pages' @gh_fqdn = fqdn @gh_url = options[:github_url] || 'github.com' @gh_token = option(:github_token) @gh_email = options[:email] || 'deploy@travis-ci.org' @gh_name = "#{options[:name] || 'Deployment Bot'} (from Travis CI)" @gh_ref = "#{@gh_url}/#{slug}.git" end
Public Instance Methods
check_auth()
click to toggle source
# File lib/dpl/provider/pages.rb, line 47 def check_auth end
fqdn()
click to toggle source
# File lib/dpl/provider/pages.rb, line 39 def fqdn options.fetch(:fqdn) { nil } end
github_deploy()
click to toggle source
# File lib/dpl/provider/pages.rb, line 54 def github_deploy context.shell 'rm -rf .git > /dev/null 2>&1' context.shell "touch \"deployed at `date` by #{@gh_name}\"" context.shell 'git init' or raise 'Could not create new git repo' context.shell "git config user.email '#{@gh_email}'" context.shell "git config user.name '#{@gh_name}'" context.shell "echo '#{@gh_fqdn}' > CNAME" if @gh_fqdn context.shell 'git add .' context.shell "FILES=\"`git commit -m 'Deploy #{@project_name} to #{@gh_ref}:#{@target_branch}' | tail`\"; echo \"$FILES\"; echo \"$FILES\" | [ `wc -l` -lt 10 ] || echo '...'" context.shell "git push --force --quiet 'https://#{@gh_token}@#{@gh_ref}' master:#{@target_branch} > /dev/null 2>&1" end
needs_key?()
click to toggle source
# File lib/dpl/provider/pages.rb, line 50 def needs_key? false end
push_app()
click to toggle source
# File lib/dpl/provider/pages.rb, line 66 def push_app Dir.mktmpdir {|tmpdir| FileUtils.cp_r("#{@build_dir}/.", tmpdir) FileUtils.cd(tmpdir, :verbose => true) do unless github_deploy error "Couldn't push the build to #{@gh_ref}:#{@target_branch}" end end } end
slug()
click to toggle source
# File lib/dpl/provider/pages.rb, line 43 def slug options.fetch(:repo) { context.env['TRAVIS_REPO_SLUG'] } end