Sha256: 8822507b0c0a753b838a61458ce044c4f46a3f6f1e3d5ac09cbf901426b943dd
Contents?: true
Size: 1.27 KB
Versions: 6
Compression:
Stored size: 1.27 KB
Contents
require "filesize" module Lono::Script class Upload < Base include Lono::AwsServices include Lono::Utils::Pretty include Lono::Utils::Logging def run return unless scripts_built? upload(tarball_path) logger.info "Uploaded #{File.basename(s3_dest)} to s3." end def upload(tarball_path) logger.info "Uploading scripts.tgz (#{filesize}) to #{s3_dest}" obj = s3_resource.bucket(bucket_name).object(key) start_time = Time.now obj.upload_file(tarball_path) time_took = pretty_time(Time.now-start_time).color(:green) logger.info "Time took to upload code to s3: #{time_took}" end def filesize Filesize.from(File.size(tarball_path).to_s + " B").pretty end def s3_dest "s3://#{bucket_name}/#{key}" end def key # Example key: cloudformation/development/scripts/scripts-md5 "#{dest_folder}/#{File.basename(tarball_path)}" end def bucket_name Lono::S3::Bucket.name end def dest_folder "#{Lono.env}/scripts" end # Scripts are only built if the scripts folder is non empty def scripts_built? File.exist?(SCRIPTS_INFO_PATH) && !tarball_path.empty? end def tarball_path IO.read(SCRIPTS_INFO_PATH).strip end end end
Version data entries
6 entries across 6 versions & 1 rubygems