Class: DPL::Provider::Pages
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
apt_get, #check_app, #cleanup, #commit_msg, context, #create_key, #default_text_charset, #default_text_charset?, #deploy, deprecated, #detect_encoding?, #encoding_for, #error, experimental, #log, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn
Constructor Details
#initialize(context, options) ⇒ Pages
Returns a new instance of Pages.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# 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] || '[email protected]'
@gh_name = "#{options[:name] || 'Deployment Bot'} (from Travis CI)"
@gh_ref = "#{@gh_url}/#{slug}.git"
end
|
Instance Method Details
#check_auth ⇒ Object
47
48
|
# File 'lib/dpl/provider/pages.rb', line 47
def check_auth
end
|
#fqdn ⇒ Object
39
40
41
|
# File 'lib/dpl/provider/pages.rb', line 39
def fqdn
options.fetch(:fqdn) { nil }
end
|
#github_deploy ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# 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? ⇒ Boolean
50
51
52
|
# File 'lib/dpl/provider/pages.rb', line 50
def needs_key?
false
end
|
#push_app ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# 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 ⇒ Object
43
44
45
|
# File 'lib/dpl/provider/pages.rb', line 43
def slug
options.fetch(:repo) { context.env['TRAVIS_REPO_SLUG'] }
end
|