class Object
Public Instance Methods
assert_options_present(*mandatory)
click to toggle source
# File exe/create-github-deploy, line 8 def assert_options_present(*mandatory) missing = mandatory.select{ |param| $options[param].nil? } unless missing.empty? raise OptionParser::MissingArgument.new(missing.join(', ')) end end
create_deployment()
click to toggle source
# File exe/create-github-deploy, line 101 def create_deployment deployment = $client.create_deployment($options[:repo], $options[:ref], auto_merge: false, required_contexts: [], environment: $options[:environment], transient_environment: false, production_environment: $options[:environment].start_with?('prod'), description: "Automatic deploy" ) return deployment[:url] end
create_deployment_status()
click to toggle source
# File exe/create-github-deploy, line 114 def create_deployment_status assert_options_present(:deployment_url, :state) deployment_status = $client.create_deployment_status($options[:deployment_url], $options[:state], $options.slice(:description, :log_url, :environment)) return deployment_status[:url] end
get_token()
click to toggle source
# File exe/create-github-deploy, line 120 def get_token assert_options_present(:client_id, :client_secret) print "Enter login: " login = gets.chomp print "Enter password: " password = STDIN.noecho(&:gets).chomp puts basic_auth_client = Octokit::Client.new(login: login, password: password) tfa_code = nil begin basic_auth_client.user rescue Octokit::OneTimePasswordRequired => e print "2FA code: " tfa_code = STDIN.noecho(&:gets).chomp puts end authorization = basic_auth_client.create_authorization({ scopes: ["user", "repo_deployment"], note: "create-github-deploy token generated at #{Time.now} on #{`hostname`}", client_id: $options[:client_id], client_secret: $options[:client_secret], headers: { "X-GitHub-OTP" => tfa_code } }) puts "New authorization token generated: #{authorization[:token]}" end