class Fastlane::Actions::AppStoreConnectApiKeyAddToRemoteAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb, line 58 def self.available_options [ FastlaneCore::ConfigItem.new( key: :git_repo_url, env_name: "APP_STORE_CONNECT_API_KEY_GIT_REPO_URL", description: "Git repo URL where AppStore Connect's Api Key should be stored in", type: String ), FastlaneCore::ConfigItem.new( key: :git_repo_branch, env_name: "APP_STORE_CONNECT_API_KEY_GIT_REPO_BRANCH", description: "Git repo branch where AppStore Connect's Api Key should be stored in", type: String, default_value: 'master' ), FastlaneCore::ConfigItem.new( key: :key_filepath, env_name: "APP_STORE_CONNECT_API_KEY_KEY_FILEPATH", description: "The path to the key p8 file", optional: true, conflicting_options: [:key_content], verify_block: proc do |value| UI.user_error!("Couldn't find key p8 file at path '#{value}'") unless File.exist?(File.expand_path(value)) end ), FastlaneCore::ConfigItem.new( key: :key_id, env_name: "APP_STORE_CONNECT_API_KEY_KEY_ID", description: "The key ID", ), FastlaneCore::ConfigItem.new( key: :key_content, env_name: "APP_STORE_CONNECT_API_KEY_KEY", description: "The content of the key p8 file", sensitive: true, optional: true, conflicting_options: [:key_filepath] ), FastlaneCore::ConfigItem.new( key: :is_key_content_base64, env_name: "APP_STORE_CONNECT_API_KEY_IS_KEY_CONTENT_BASE64", description: "Whether :key_content is Base64 encoded or not", type: Boolean, default_value: false ) ] end
description()
click to toggle source
@!group Documentation
# File lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb, line 54 def self.description "Add/Update AppStore Connect API Key to the remote git repo" end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb, line 110 def self.is_supported?(platform) [:ios, :mac].include?(platform) end
run(options)
click to toggle source
# File lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb, line 8 def self.run(options) git_repo_url = options[:git_repo_url] git_repo_branch = options[:git_repo_branch] key_filepath = options[:key_filepath] key_id = options[:key_id] key_content = options[:key_content] is_key_content_base64 = options[:is_key_content_base64] if key_content.nil? && key_filepath.nil? UI.user_error!(":key_content or :key_filepath is required") end Helper::GitHelper.clone_repo_in_tmp(git_repo_url, git_repo_branch, true) do |dir| target_filename = "#{key_id}.p8" target_filepath = File.join(dir, target_filename) if key_filepath.nil? == false FileUtils.cp(File.expand_path(key_filepath), target_filepath) else File.open(target_filepath, 'w') do |file| if is_key_content_base64 file.write(Base64.decode64(key_content)) else file.write(key_content) end end end repo_status = Actions.sh("git status --porcelain") repo_clean = repo_status.empty? if repo_clean UI.message("Skipping key #{key_id} update since it contents remains the same") else UI.message("Adding / updating #{key_id}") Actions.sh("git add #{target_filename} && git commit -m '[AppStore Connect API Key] Add/Update #{target_filename} key'") Actions.sh("git push -f #{git_repo_url} #{git_repo_branch}") end end end