Commit 52c23bc

mo khan <mo@mokhan.ca>
2015-05-29 04:45:54
extract bucket name.
1 parent 63b930b
Changed files (3)
config
lib
capistrano
tasks
config/deploy.rb
@@ -15,6 +15,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
 # Default value for :scm is :git
 #set :scm, :git
 set :scm, :s3
+set :bucket_name, "stronglifters"
 
 # Default value for :format is :pretty
 # set :format, :pretty
lib/capistrano/s3.rb
@@ -17,7 +17,7 @@ class Capistrano::S3 < Capistrano::SCM
     end
 
     def check
-      s3 'ls stronglifters'
+      s3 "ls #{bucket_name}"
     end
 
     def clone
@@ -25,14 +25,24 @@ class Capistrano::S3 < Capistrano::SCM
     end
 
     def update
-      build = "stronglifters-2015-05-29-03-07-33.tar.gz"
-      s3 "cp s3://stronglifters/production/#{build} #{repo_path}/#{build}"
+      s3 "cp s3://#{bucket_name}/#{rails_env}/#{build_revision} #{repo_path}/#{build_revision}"
     end
 
     def release
-      build = "stronglifters-2015-05-29-03-07-33.tar.gz"
       context.execute("mkdir -p #{release_path}")
-      context.execute("tar -xvzf #{repo_path}/#{build} --strip-components=1 -C #{release_path}")
+      context.execute("tar -xvzf #{repo_path}/#{build_revision} --strip-components=1 -C #{release_path}")
+    end
+
+    def bucket_name
+      fetch(:bucket_name)
+    end
+
+    def rails_env
+      fetch(:rails_env)
+    end
+
+    def build_revision
+      "stronglifters-2015-05-29-03-07-33.tar.gz"
     end
   end
 end
lib/tasks/s3.rake
@@ -5,8 +5,6 @@ namespace :s3 do
 
   set :s3_environmental_variables, ->() {
     {
-      aws_access_key_id: fetch(:aws_access_key_id),
-      aws_secret_access_key: fetch(:aws_secret_access_key),
       bucket_name: fetch(:s3_bucket),
       build_revision: fetch(:build_revision),
     }