Class: Fastlane::Actions::MaestroOrchestrationS3UploadAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::MaestroOrchestrationS3UploadAction
- Defined in:
- lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_s3_upload_action.rb
Class Method Summary collapse
- .available_options ⇒ Object
- .description ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.available_options ⇒ Object
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_s3_upload_action.rb', line 48 def self. [ FastlaneCore::ConfigItem.new( key: :folder_path, env_name: "MAESTRO_SCREENSHOTS_FOLDER_PATH", description: "Path to the folder to be uploaded to S3", optional: false, verify_block: proc do |value| UI.user_error!("You must provide a valid folder path using the `folder_path` parameter.") unless value && !value.strip.empty? UI.user_error!("The folder path does not exist: #{value}") unless File.directory?(value) end ), FastlaneCore::ConfigItem.new( key: :bucket, env_name: "MAESTRO_SCREENSHOTS_S3_BUCKET", description: "The S3 bucket name where files will be uploaded", optional: false, verify_block: proc do |value| UI.user_error!("You must provide a valid S3 bucket name using the `bucket` parameter.") unless value && !value.strip.empty? end ), FastlaneCore::ConfigItem.new( key: :s3_path, env_name: "MAESTRO_SCREENSHOTS_S3_PATH", description: "The base S3 path (after the bucket name) where files will be uploaded: $bucket/$s3_path", optional: false ), FastlaneCore::ConfigItem.new( key: :version, env_name: "MAESTRO_SCREENSHOTS_APP_VERSION", description: "Version of the app that screenshots are taken from", optional: false, verify_block: proc do |value| UI.user_error!("You must provide a version using the `version` parameter.") unless value && !value.strip.empty? end ), FastlaneCore::ConfigItem.new( key: :device, env_name: "MAESTRO_SCREENSHOTS_DEVICE", description: "Device type: android or ios", type: String, optional: false ), FastlaneCore::ConfigItem.new( key: :theme, env_name: "MAESTRO_SCREENSHOTS_APPLICATION_THEME", description: "Optional theme parameter (e.g., dark or light)", default_value: nil, optional: true ) ] end |
.description ⇒ Object
44 45 46 |
# File 'lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_s3_upload_action.rb', line 44 def self.description "Uploads files to an S3 bucket." end |
.is_supported?(platform) ⇒ Boolean
101 102 103 |
# File 'lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_s3_upload_action.rb', line 101 def self.is_supported?(platform) true end |
.run(params) ⇒ Object
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 |
# File 'lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_s3_upload_action.rb', line 9 def self.run(params) required_params = [:folder_path, :bucket, :version, :device] missing_params = required_params.select { |param| params[param].nil? } if missing_params.any? missing_params.each do |param| UI.error("Missing parameter: #{param}") end raise "Missing required parameters: #{missing_params.join(', ')}" end UI.("Uploading screenshots to S3...") s3_client = Aws::S3::Client.new( region: ENV.fetch('AWS_REGION', 'us-east-1') ) base_path = "#{params[:s3_path]}/ver:#{params[:version]}" base_path += "/theme:#{params[:theme]}" if params[:theme] base_path += "/device:#{params[:device]}" UI.("Folder path: #{params[:folder_path]}") Dir.glob("#{params[:folder_path]}/*").each do |file| next if File.directory?(file) file_name = File.basename(file) s3_key = File.join(base_path, file_name) UI.("Uploading #{file} to s3://#{params[:bucket]}/#{s3_key}") s3_client.put_object(bucket: params[:bucket], key: s3_key, body: File.open(file)) end UI.success("Upload to S3 completed.") end |