Class: Fastlane::Actions::UploadToOneskyAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



27
28
29
# File 'lib/fastlane/plugin/upload_to_onesky/actions/upload_to_onesky_action.rb', line 27

def self.authors
  ['JMoravec', 'joshrlesch']
end

.available_optionsObject



31
32
33
34
35
36
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
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/fastlane/plugin/upload_to_onesky/actions/upload_to_onesky_action.rb', line 31

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :public_key,
                                 env_name: 'ONESKY_PUBLIC_KEY',
                                 description: 'Public key for OneSky',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise "No Public Key for OneSky given, pass using `public_key: 'token'`".red unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :secret_key,
                                 env_name: 'ONESKY_SECRET_KEY',
                                 description: 'Secret Key for OneSky',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise "No Secret Key for OneSky given, pass using `secret_key: 'token'`".red unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :project_id,
                                 env_name: 'ONESKY_PROJECT_ID',
                                 description: 'Project Id to upload file to',
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise 'No project id given'.red unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :strings_file_path,
                                 env_name: 'ONESKY_STRINGS_FILE_PATH',
                                 description: 'Base file path for the strings file to upload',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise "Couldn't find file at path '#{value}'".red unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :strings_file_format,
                                 env_name: 'ONESKY_STRINGS_FORMAT',
                                 description: 'Format of the strings file: see https://github.com/onesky/api-documentation-platform/blob/master/reference/format.md',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise 'No file format given'.red unless (value and not value.empty?)
                                 end)
  ]
end

.descriptionObject



23
24
25
# File 'lib/fastlane/plugin/upload_to_onesky/actions/upload_to_onesky_action.rb', line 23

def self.description
  'Upload a strings file to OneSky'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
78
79
80
81
# File 'lib/fastlane/plugin/upload_to_onesky/actions/upload_to_onesky_action.rb', line 75

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fastlane/plugin/upload_to_onesky/actions/upload_to_onesky_action.rb', line 4

def self.run(params)
  Actions.verify_gem!('onesky-ruby')
  require 'onesky'

  client = Onesky::Client.new(params[:public_key], params[:secret_key])

  project = client.project(params[:project_id])

  UI.success 'Starting the upload to OneSky'
  resp = project.upload_file(file: params[:strings_file_path], file_format: params[:strings_file_format])

  if resp.code == 201
    UI.success "#{File.basename params[:strings_file_path]} was successfully uploaded to project #{params[:project_id]} in OneSky"
  else
    UI.error "Error uploading file to OneSky, Status code is #{resp.code}"
  end

end