Class: OdaniaStaticPages::Deploy::S3
- Inherits:
-
Object
- Object
- OdaniaStaticPages::Deploy::S3
- Defined in:
- lib/odania_static_pages/deploy/s3.rb
Instance Method Summary collapse
-
#initialize ⇒ S3
constructor
A new instance of S3.
- #prepare ⇒ Object
- #publish(color) ⇒ Object
Constructor Details
#initialize ⇒ S3
Returns a new instance of S3.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/odania_static_pages/deploy/s3.rb', line 4 def initialize @config = OdaniaStaticPages.config @s3_config = @config.current_environment.deploy_module params = { region: @s3_config.region } params[:profile] = @s3_config.profile unless @s3_config.profile.nil? puts "Configuring AWS with params: #{params}" Aws.config.update(params) end |
Instance Method Details
#prepare ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/odania_static_pages/deploy/s3.rb', line 16 def prepare = @s3_config. logging_stack_name = 'odania-logging' params = { BucketName: @s3_config.logging_bucket } Stacker.create_or_update_stack(logging_stack_name, File.join(@config.base_dir, 'cf-templates', 's3-logging.yml'), params, nil, nil, ) params = { BucketName: @s3_config.state_bucket } Stacker.create_or_update_stack('odania-state', File.join(@config.base_dir, 'cf-templates', 's3-state.yml'), params, nil, nil, ) params = { BucketNameGreen: @s3_config.bucket_name_green, BucketNameBlue: @s3_config.bucket_name_blue, LoggingStackName: logging_stack_name } Stacker.create_or_update_stack('odania-static-http', File.join(@config.base_dir, 'cf-templates', 's3-http.yml'), params, logging_stack_name, nil, ) end |
#publish(color) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/odania_static_pages/deploy/s3.rb', line 37 def publish(color) puts 'Publishing website to s3' load_state color = color.nil? ? @state[:color] : color new_color = 'green'.eql?(color) ? 'blue' : 'green' puts " -> Current color: #{color}" @site_path = @config.output_site_path puts " -> Deploying to color: #{new_color} [Path: #{@site_path}]" @uploaded_files = [] bucket_name = 'green'.eql?(new_color) ? @s3_config.bucket_name_green : @s3_config.bucket_name_blue recursive_file_upload bucket_name, @site_path delete_not_uploaded_files bucket_name @state[:color] = new_color save_state url = bucket_url bucket_name @config.current_environment.do_notify new_color, color puts puts "Finished deploying color #{new_color} to bucket #{bucket_name}" puts "Public url: #{url}" end |