Class: Fastlane::Actions::DecryptFastlaneVarsAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



91
92
93
94
# File 'lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb', line 91

def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ["cball", "isaiahgrey93"]
end

.available_optionsObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb', line 65

def self.available_options
  # Define all options your action supports. 
  
  # Below a few examples
  [
    FastlaneCore::ConfigItem.new(key: :set_env,
                                 env_name: "FL_DECRYPT_FASTLANE_VARS_SET_ENV", # The name of the environment variable
                                 description: "Sets the decrypted values in env", # a short description of this parameter
                                 type: Boolean,
                                 default_value: true),
    FastlaneCore::ConfigItem.new(key: :write_env,
                                 env_name: "FL_DECRYPT_FASTLANE_VARS_WRITE_ENV", # The name of the environment variable
                                 description: "If we should write fastlane .env files", # a short description of this parameter
                                 type: Boolean,
                                 default_value: true)
  ]
end

.descriptionObject



56
57
58
# File 'lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb', line 56

def self.description
  "Decrypts fastlane ENV vars from the encrypted repo. Optionally sets them in ENV."
end

.detailsObject



60
61
62
63
# File 'lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb', line 60

def self.details
  # Optional:
  # this is your chance to provide a more detailed description of this action
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb', line 96

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

.return_valueObject



83
84
85
# File 'lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb', line 83

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb', line 7

def self.run(params)

  is_ci = ENV['CI'] === 'true'
  write_env = params[:write_env]

  env = other_action.cryptex(
    type: "export_env",
    key: Helper::ReactNativeReleaseHelper::FASTLANE_CRYPTEX_KEY,
    set_env: params[:set_env]
  )

  should_write_env = write_env && !is_ci


  UI.success('Successfully decrypted fastlane vars.')

  # write fastlane env files
  if (should_write_env)

    UI.success('Writing fastlane vars to <root>/fastlane/.env.')
    
    open('./fastlane/.env', 'w') do |f|
      env.each {|key, value| f.puts "#{key}=#{value}" }
    end
 
    UI.success('Writing fastlane vars to <root>/ios/fastlane/.env.')
    
    open('./ios/fastlane/.env', 'w') do |f|
      env.each {|key, value| f.puts "#{key}=#{value}" }
    end
 
    UI.success('Writing fastlane vars to <root>/android/fastlane/.env.')
    
    open('./android/fastlane/.env', 'w') do |f|
      env.each {|key, value| f.puts "#{key}=#{value}" }
    end

    UI.success('Fastlane .env files were successfully written.')
  else
    UI.success('Fastlane .env not generated.')
  end

  env
end