Class: Fastlane::Actions::FirebaseManagementApiUploadShaAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



44
45
46
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb', line 44

def self.authors
	["NicoLourenco"]
end

.available_optionsObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb', line 57

def self.available_options
	[
		FastlaneCore::ConfigItem.new(key: :email,
								env_name: "FIREBASE_EMAIL",
							 description: "User's email to identify stored credentials",
								optional: true),

		FastlaneCore::ConfigItem.new(key: :client_secret_json_path,
								env_name: "FIREBASE_CLIENT_SECRET_JSON_PATH",
							 description: "Path to client secret json file",
								optional: true),

		FastlaneCore::ConfigItem.new(key: :service_account_json_path,
								env_name: "FIREBASE_SERVICE_ACCOUNT_JSON_PATH",
							 description: "Path to service account json key",
								optional: true),

		FastlaneCore::ConfigItem.new(key: :project_id,
								env_name: "FIREBASE_PROJECT_ID",
							 description: "Project id",
								optional: true),

		FastlaneCore::ConfigItem.new(key: :app_id,
								env_name: "FIREBASE_APP_ID",
							 description: "Project app id",
								optional: true),

		FastlaneCore::ConfigItem.new(key: :sha_hash,
								env_name: "FIREBASE_SHA_HASH",
							 description: "Sha hash",
								optional: false),

		FastlaneCore::ConfigItem.new(key: :download_config,
								env_name: "FIREBASE_DOWNLOAD_CONFIG",
							 description: "Should download config for created client",
								optional: false,
								is_string: false,
								default_value: false),

		FastlaneCore::ConfigItem.new(key: :cert_type,
								env_name: "FIREBASE_CERT_TYPE",
							 description: "Type of certificate (SHA_1, SHA_256)",
							 optional: false,
								verify_block: proc do |value|
									types = [:SHA_1, :SHA_256]
									UI.user_error!("Type must be in #{types}") unless types.include?(value.to_sym)
								end
							 ),

		FastlaneCore::ConfigItem.new(key: :output_path,
		                        env_name: "FIREBASE_OUTPUT_PATH",
		                     description: "Path for the downloaded config",
		                        optional: false,
		                   default_value: "./"),

		FastlaneCore::ConfigItem.new(key: :output_name,
		                        env_name: "FIREBASE_OUTPUT_NAME",
		                     description: "Name of the downloaded file",
		                        optional: true)
	]	
end

.descriptionObject



40
41
42
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb', line 40

def self.description
	"Add sha to to Firebase android app"
end

.detailsObject



52
53
54
55
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb', line 52

def self.details
	# Optional:
	"Firebase plugin helps you list your projects, create applications and download configuration files."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


119
120
121
122
123
124
125
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb', line 119

def self.is_supported?(platform)
	# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
	# See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
	#
	# [:ios, :mac, :android].include?(platform)
	true
end

.return_valueObject



48
49
50
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb', line 48

def self.return_value
	# If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_add_app_sha_action.rb', line 5

def self.run(params)
	manager = FirebaseManagementApi::Manager.new
	
	# login
	api = nil
	if params[:service_account_json_path] != nil then
		api = manager.serviceAccountLogin(params[:service_account_json_path])
	elsif params[:email] != nil && params[:client_secret_json_path] != nil then
		api = manager.userLogin(params[:email], params[:client_secret_json_path])
	else
		UI.error "You must define service_account_json_path or email with client_secret_json_path."
		return nil
	end

	# select project
	project_id = params[:project_id] || manager.select_project(nil)["projectId"]
	
	# select app
	app_id = params[:app_id] || manager.select_app(project_id, nil, :android)["appId"]

	# create new android app on Firebase
	api.upload_sha(project_id, app_id, params[:sha_hash], params[:cert_type])

	if params[:download_config] then
		#Download config
		Actions::FirebaseManagementApiDownloadConfigAction.run(
			service_account_json_path: params[:service_account_json_path],
			project_id: project_id,
			app_id: app["appId"],
			type: type,
			output_path: params[:output_path]
		)
	end
end