Class: Fastlane::Actions::AppStoreConnectApiKeyRemoveFromRemoteAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



60
61
62
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb', line 60

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

.available_optionsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb', line 37

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",
    )
  ]
end

.descriptionObject



33
34
35
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb', line 33

def self.description
  "Remove AppStore Connect API Key from the remote git repo"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb', line 64

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

.run(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb', line 8

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

  Helper::GitHelper.clone_repo_in_tmp(repo_url: git_repo_url, branch: git_repo_branch) do |dir|
    target_filename = "#{key_id}.p8"
    target_filepath = File.join(dir, target_filename)

    if File.exist?(target_filepath)
      UI.message("Removing '#{key_id}.p8' at #{git_repo_url}")
      FileUtils.rm(target_filepath)

      Actions.sh("git rm #{target_filename} && git commit -m '[AppStore Connect API Key] Remove '#{key_id}.p8' key'")
      Actions.sh("git push -f #{git_repo_url} #{git_repo_branch}")    
    else
      UI.message("Skipping remove of '#{key_id}.p8' as no file has been found at #{git_repo_url}")
    end
  end
end