Class: Fastlane::Actions::EncryptSecretsAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



24
25
26
# File 'lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb', line 24

def self.authors
  ["Cyril Cermak, Jörg Nestele"]
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
59
60
61
# File 'lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb', line 37

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :hash_key,
                                 description: "Key that will be used to hash the secrets using XOR technique and encrypt files with AES, if files are encrypted the password must have 32 characters as an AES standard",
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :language,
                                 description: "Source code language, currently supported - [swift]",
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :secrets_dir_path,
                                  description: "Path to a directory where .gpg was initialized",
                                  is_string: true),
    FastlaneCore::ConfigItem.new(key: :should_include_password,
                                 description: "Defines whether the password will be added to the output file or whether it will be provided externally",
                                 type: Boolean,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :secrets,
                                 description: "Key-value dictionary of secrets",
                                 type: Hash,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :files,
                                 description: "Array of files that will be encrypted",
                                 type: Array,
                                 optional: true)
  ]
end

.clean(file_path) ⇒ Object



33
34
35
# File 'lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb', line 33

def self.clean file_path
  File.delete(file_path) if File.exist?(file_path)
end

.descriptionObject



20
21
22
# File 'lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb', line 20

def self.description
  "Securely store secrets in source code"
end

.detailsObject



28
29
30
31
# File 'lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb', line 28

def self.details
  # Optional:
  ""
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
66
67
68
69
# File 'lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb', line 63

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  [:ios, :mac].include?(platform)
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb', line 8

def self.run(params)
  hash_key = params[:hash_key]
  language = params[:language]
  secrets_dir_path = params[:secrets_dir_path]
  secrets_dict = params[:secrets]
  files = params[:files]
  includes_password = params[:should_include_password]
  config_yml = {"MobileSecrets" => {"hashKey"=>hash_key,"language"=>language, "shouldIncludePassword"=>includes_password, "secrets"=>secrets_dict, "files"=>files}}.to_yaml

  MobileSecrets::SecretsHandler.new.encrypt "#{secrets_dir_path}/secrets.gpg", config_yml, secrets_dir_path
end