class Fastlane::Actions::AppStoreConnectApiKeyRemoveFromRemoteAction

Public Class Methods

authors() click to toggle source
# 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_options() click to toggle source
# 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
description() click to toggle source

@!group Documentation

# 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) click to toggle source
# 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) click to toggle source
# 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(git_repo_url, git_repo_branch, false) 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