Class: Fastlane::Actions::S3CheckFileAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



32
33
34
# File 'lib/fastlane/plugin/s3_actions/actions/s3_check_file_action.rb', line 32

def self.authors
  ["Fernando Saragoca"]
end

.available_optionsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fastlane/plugin/s3_actions/actions/s3_check_file_action.rb', line 40

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :access_key_id,
                            env_name: "S3_ACTIONS_ACCESS_KEY_ID",
                         description: "AWS Access Key",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :secret_access_key,
                            env_name: "S3_ACTIONS_SECRET_ACCESS_KEY",
                         description: "AWS Secret Access Key",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :bucket,
                            env_name: "S3_ACTIONS_BUCKET",
                         description: "S3 Bucket",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :file_name,
                            env_name: "S3_ACTIONS_CHECK_FILE_NAME",
                         description: "File name",
                            optional: false,
                                type: String)
  ]
end

.descriptionObject



28
29
30
# File 'lib/fastlane/plugin/s3_actions/actions/s3_check_file_action.rb', line 28

def self.description
  "Check if file exists in AWS S3"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/fastlane/plugin/s3_actions/actions/s3_check_file_action.rb', line 65

def self.is_supported?(platform)
  true
end

.return_valueObject



36
37
38
# File 'lib/fastlane/plugin/s3_actions/actions/s3_check_file_action.rb', line 36

def self.return_value
  "Returns 'true' if object exists, 'false' if not"
end

.run(params) ⇒ Object



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

def self.run(params)
  Actions.verify_gem!('s3')

  service = S3::Service.new(access_key_id: params[:access_key_id],
                        secret_access_key: params[:secret_access_key])

  bucket_name = params[:bucket]
  file_name = params[:file_name]

  bucket = service.buckets.find(bucket_name)
  if bucket.nil?
    UI.user_error! "Bucket '#{bucket_name}' not found, please verify bucket and credentials 🚫"
  end

  begin
    bucket.objects.find(file_name)
    true
  rescue
    false
  end
end