class Dpl::Providers::GitPush
Public Instance Methods
Source
# File lib/dpl/providers/git_push.rb, line 92 def deploy git_clone copy_files return info :stop unless git_dirty? push pull_request if pull_request? end
Source
# File lib/dpl/providers/git_push.rb, line 84 def login token? ? login_token : setup_deploy_key end
Source
# File lib/dpl/providers/git_push.rb, line 107 def pull_request pr_exists? ? info(:pr_exists) : create_pr end
Source
# File lib/dpl/providers/git_push.rb, line 101 def push git_config git_commit git_push end
Source
# File lib/dpl/providers/git_push.rb, line 79 def setup info :setup info :git_config end
Source
# File lib/dpl/providers/git_push.rb, line 75 def validate error :same_branch if same_branch? && !allow_same_branch? end
Private Instance Methods
Source
# File lib/dpl/providers/git_push.rb, line 264 def api_url enterprise? ? "https://#{host}/api/v3/" : 'https://api.github.com/' end
Source
# File lib/dpl/providers/git_push.rb, line 153 def branch_exists? git_ls_remote?(remote_url, branch) end
Source
# File lib/dpl/providers/git_push.rb, line 140 def clone_branch branch_exists? ? branch : base_branch end
Source
# File lib/dpl/providers/git_push.rb, line 144 def copy_files shell :copy_files end
Source
# File lib/dpl/providers/git_push.rb, line 251 def create_pr pr = github.create_pull_request(repo, base_branch, branch, "Update #{base_branch}") info :pr_created, number: pr.number end
Source
# File lib/dpl/providers/git_push.rb, line 189 def email str = super if email? str || user_email end
Calls superclass method
Source
# File lib/dpl/providers/git_push.rb, line 135 def git_clone shell :git_clone, echo: false shell :git_branch unless branch_exists? end
Source
# File lib/dpl/providers/git_push.rb, line 157 def git_commit shell :git_commit_hook, path: asset(:git, :detect_private_key).path, echo: false if deploy_key? shell :git_add shell :git_commit shell :git_show end
Source
# File lib/dpl/providers/git_push.rb, line 176 def git_commit_msg_opts msg = interpolate(commit_message, vars:) msg.split("\n").reject(&:empty?).map { |message| %(-m #{quote(message)}) } end
Source
# File lib/dpl/providers/git_push.rb, line 172 def git_commit_opts ' --allow-empty' if allow_empty_commit? end
Source
# File lib/dpl/providers/git_push.rb, line 148 def git_config shell :git_config_name, echo: false shell :git_config_email, echo: false end
Source
# File lib/dpl/providers/git_push.rb, line 164 def git_push shell :git_push, echo: false end
Source
# File lib/dpl/providers/git_push.rb, line 168 def git_push_opts '--force' if force? end
Source
# File lib/dpl/providers/git_push.rb, line 207 def git_url "git@#{host}:#{slug}.git" end
Source
# File lib/dpl/providers/git_push.rb, line 260 def github @github ||= Octokit::Client.new(access_token: token, api_endpoint: api_url, auto_paginate: true) end
Source
# File lib/dpl/providers/git_push.rb, line 256 def github? host.include?('github') || enterprise? end
Source
# File lib/dpl/providers/git_push.rb, line 203 def https_url_with_token "https://#{token}@#{url}" end
Source
# File lib/dpl/providers/git_push.rb, line 117 def login_token return unless github? info :login, user.login error :insufficient_scopes unless sufficient_scopes? rescue Octokit::Unauthorized => e error :invalid_token, e.message end
Source
# File lib/dpl/providers/git_push.rb, line 181 def name str = super if name? str ||= user_name str = "#{str} (via Travis CI)" if ENV['TRAVIS'] && !name? str end
Calls superclass method
Source
# File lib/dpl/providers/git_push.rb, line 247 def pr_exists? !!github.pulls(repo).detect { |pull| pull.head.ref == branch } end
Source
# File lib/dpl/providers/git_push.rb, line 195 def project_name super || repo_slug end
Calls superclass method
Source
# File lib/dpl/providers/git_push.rb, line 199 def remote_url token? ? https_url_with_token : git_url end
Source
# File lib/dpl/providers/git_push.rb, line 113 def same_branch? git_branch == branch end
Source
# File lib/dpl/providers/git_push.rb, line 243 def scopes @scopes ||= github.scopes end
Source
# File lib/dpl/providers/git_push.rb, line 126 def setup_deploy_key path = '~/.dpl/deploy_key' info(:setup_deploy_key, path:) mv deploy_key, path chmod 0o600, path setup_git_ssh path shell :check_deploy_key, key: path end
Source
# File lib/dpl/providers/git_push.rb, line 219 def src_dir @src_dir ||= expand(local_dir) end
Source
# File lib/dpl/providers/git_push.rb, line 227 def sufficient_scopes? scopes.include?('public_repo') || scopes.include?('repo') end
Source
# File lib/dpl/providers/git_push.rb, line 235 def user_name user.name || user.login end
Source
# File lib/dpl/providers/git_push.rb, line 223 def work_dir @work_dir ||= tmp_dir end