Class: Fastlane::Actions::AppStoreConnectApiKeySetFromRemoteAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



82
83
84
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb', line 82

def self.authors
  ["Dima Vorona", "Yalantis"]
end

.available_optionsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb', line 43

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_id,
          env_name: "APP_STORE_CONNECT_API_KEY_KEY_ID",
          description: "The key ID",
      ),
      FastlaneCore::ConfigItem.new(
          key: :issuer_id,
          env_name: "APP_STORE_CONNECT_API_KEY_ISSUER_ID",
          description: "The issuer ID"
      ),
      FastlaneCore::ConfigItem.new(
          key: :in_house,
          env_name: "APP_STORE_CONNECT_API_KEY_IN_HOUSE",
          description: "Is App Store or Enterprise (in house) team? App Store Connect API cannot determine this on its own (yet)",
          type: Boolean,
          default_value: false
      )
  ]
end

.descriptionObject



39
40
41
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb', line 39

def self.description
  "Add/Update AppStore Connect API Key to the remote git repo"
end

.is_supported?(platform) ⇒ Boolean



86
87
88
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb', line 86

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.outputObject



78
79
80
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb', line 78

def self.output
  Fastlane::Actions::AppStoreConnectApiKeyAction.output
end

.run(options) ⇒ Object



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
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb', line 7

def self.run(options)
  git_repo_url = options[:git_repo_url]
  git_repo_branch = options[:git_repo_branch]

  key_id = options[:key_id]
  issuer_id = options[:issuer_id]
  in_house = options[:in_house]
  
  Helper::GitHelper.clone_repo_in_tmp(repo_url: git_repo_url, branch: git_repo_branch) do |dir|
    target_filename = "#{key_id}.p8"
    target_filepath = Pathname.new File.join(dir, target_filename)
  
    if target_filepath.exist?
      UI.message("Setting contents of #{target_filename} as a API Key")
      
      Fastlane::Actions::AppStoreConnectApiKeyAction.run(
          key_id: key_id, 
          issuer_id: issuer_id, 
          key_content: Base64.encode64(target_filepath.read), 
          is_key_content_base64: true,
          in_house: in_house
      )
    else
      UI.user_error!("No #{target_filename} has been found at #{git_repo_url}")
    end
  end
end