heroku_ops 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 387d93e0a3e2f8801af4cd0a0ff792fbe50ea3fb
4
- data.tar.gz: 6d00fdc0ce03b61fcc07e15580b6f9f39e645c91
3
+ metadata.gz: 87efff934872674d9853d7165df342cc6471d106
4
+ data.tar.gz: 1a34d491a9cd64716932edf141d038bd0596ba5f
5
5
  SHA512:
6
- metadata.gz: 8ebbb62e94d49842902a5d88b41c92e9d511b89d44771f3e5d7c5a66b515e9dc555b8efdc9a7a6abfc2ee7131b941d224b9cb87ae66555aa5c7def17c3a0e6f2
7
- data.tar.gz: 91042e589e978cd8a3564e909256d3288215dc7bbfd68e41681258dad9af45fd4bbfb9e2eb3eaf6cf927aa8ca4f7aaa81ba2c6c085f38f971921aa47ea0c613f
6
+ metadata.gz: 1852ae2ee6fbd903096d8b804cf4462da0202414bbd0f6e98f24d8538c4eb1371133c58f84012ad0f457b2ead944805f771302fe02e66371ea840e66590114cb
7
+ data.tar.gz: 3115404a1c90b71f78f2b99f6d5b93be8df238ca1ccc43836d25de3702697abc49054dc6b9c8246c11be7c601ad1a62ca2168745d2732a31875220de1b5d564f
data/heroku_ops.gemspec CHANGED
@@ -32,4 +32,6 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_development_dependency "bundler", "~> 1.13"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "heroku_rake_deploy", "~> 0.0.2"
36
+ spec.add_runtime_dependency "heroku_rake_deploy", "~> 0.0.2"
35
37
  end
@@ -1,7 +1,5 @@
1
1
  class HerokuOps::Railtie < Rails::Railtie
2
2
  rake_tasks do
3
3
  load 'tasks/pipeline_setup.rake'
4
- load 'tasks/deploy.rake'
5
- load 'tasks/db_restore.rake'
6
4
  end
7
5
  end
@@ -1,3 +1,3 @@
1
1
  module HerokuOps
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/heroku_ops.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require "heroku_ops/version"
2
2
  require "heroku_ops/railtie" if defined?(Rails)
3
-
3
+ require "heroku_rake_deploy" if defined?(Rails)
4
+ require "heroku_rake_deploy/railtie" if defined?(Rails)
5
+ require "heroku_db_restore" if defined?(Rails)
6
+ require "heroku_db_restore/railtie" if defined?(Rails)
4
7
  module HerokuOps
5
8
  # TODO DRY rake tasks by moving repeated code here
6
9
  end
@@ -2,12 +2,12 @@ def base_app_name
2
2
  "#{Rails.application.class.parent_name.underscore.gsub('_','-')}"
3
3
  end
4
4
 
5
- def app_name_for_env(env)
5
+ def app_name_from_environment(env)
6
6
  case env.downcase
7
7
  when "production"
8
- "#{base_app_name}-production"
8
+ ENV['HEROKU_APPNAME_PRODUCTION'] || "#{Rails.application.class.parent_name.underscore.gsub('_','-')}-production"
9
9
  when "staging"
10
- "#{base_app_name}-staging"
10
+ ENV['HEROKU_APPNAME_STAGING'] || "#{Rails.application.class.parent_name.underscore.gsub('_','-')}-staging"
11
11
  end
12
12
  end
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrowegt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: heroku_rake_deploy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: heroku_rake_deploy
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.2
41
69
  description: Tasks to setup pipelines for your app with the typical free tier addons
42
70
  and run deploys and db restores
43
71
  email:
@@ -57,8 +85,6 @@ files:
57
85
  - lib/heroku_ops.rb
58
86
  - lib/heroku_ops/railtie.rb
59
87
  - lib/heroku_ops/version.rb
60
- - lib/tasks/db_restore.rake
61
- - lib/tasks/deploy.rake
62
88
  - lib/tasks/pipeline_setup.rake
63
89
  homepage: https://github.com/nrowegt/heroku_ops
64
90
  licenses:
@@ -1,55 +0,0 @@
1
- DataBaseReference = ""
2
-
3
- namespace :heroku_ops do
4
- namespace :db do
5
- desc 'Pull Down a copy of the database from the specified heroku environment'
6
- task :restore do
7
- env = ENV['ENV']
8
-
9
- abort "Please specify ENV=production or ENV=staging" unless env
10
- app = app_name_from_environment(env)
11
-
12
- if ENV['LATEST'] #if this is here, then create a fresh backup, if not grab whichever is the latest
13
- sh "heroku pg:backups capture --app #{app}"
14
- end
15
-
16
- sh "curl -o tmp/latest.dump `heroku pg:backups public-url --app #{app} | head -n 1`"
17
-
18
- #ensures there are no extra tables or views
19
- Rake::Task["heroku_ops:db:restore:local"].invoke
20
- end
21
-
22
- namespace :restore do
23
- desc "Restore a local copy of Heroku's Staging Environment database"
24
- task :staging do
25
- ENV['ENV'] = "staging"
26
- Rake::Task["heroku_ops:db:restore"].invoke
27
- end
28
-
29
- desc "Restore a local copy of Heroku's Production Environment database"
30
- task :production do
31
- ENV['ENV'] = "production"
32
- Rake::Task["heroku_ops:db:restore"].invoke
33
- end
34
-
35
- desc "Erase local development and test database and restore from the local dump file."
36
- task :local do
37
- #ensures there are no extra tables or views
38
- Rake::Task["db:drop"].invoke
39
- Rake::Task["db:create"].invoke
40
-
41
- Rake::Task["heroku_ops:db:restore:from_local_dump"].invoke
42
- #migrate the database, remove sensitive information, and setup tests
43
- Rake::Task["db:migrate"].invoke
44
- Rake::Task["db:test:prepare"].invoke
45
- end
46
-
47
- desc "Restore from local dump file (defaults to '/tmp/latest.dump' - specify with DUMP_FILE Environmental Variable)"
48
- task :from_local_dump do
49
- dump_file_location = (ENV['DUMP_FILE'] || "tmp/latest.dump")
50
- #in backticks so that pg_restore warnings dont exit this routine
51
- `pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{Rails.application.class.parent_name.underscore}_development #{dump_file_location}`
52
- end
53
- end
54
- end
55
- end
@@ -1,85 +0,0 @@
1
- def app_name_from_environment(env)
2
- case env.downcase
3
- when "production"
4
- "#{Rails.application.class.parent_name.underscore.gsub('_','-')}-production"
5
- when "staging"
6
- "#{Rails.application.class.parent_name.underscore.gsub('_','-')}-staging"
7
- end
8
- end
9
-
10
- def push_command_from_env(env)
11
- case env
12
- when "production"
13
- "git push #{env} master"
14
- when "staging"
15
- # heroku requires that deployes be pushed to the master branch on heroku git repo
16
- "git push #{env} staging:master"
17
- end
18
- end
19
-
20
- namespace :heroku_ops do
21
- desc 'Deploy Safely to Heroku'
22
- task :deploy do
23
- env = ENV['ENV']
24
-
25
- abort "Please specify ENV={production|staging}" unless env
26
-
27
- app_name = app_name_from_environment(env)
28
-
29
- #take db backup first
30
- sh "heroku pg:backups capture --app #{app_name}"
31
-
32
- #push up new code release
33
- sh push_command_from_env(env)
34
-
35
- #migrate database and ensure seed values are present always (Settings, ContentMgmts)
36
- sh "heroku run rake db:migrate db:seed --app #{app_name}"
37
-
38
- #restart dynos to ensure all users get the new released version immediately
39
- sh "heroku restart --app #{app_name}"
40
-
41
- #warm up the Heroku dynos
42
- sh "curl -o /dev/null http://#{app_name}.herokuapp.com"
43
- end
44
-
45
- namespace :deploy do
46
- desc "Deploy to Heroku's Staging Environment"
47
-
48
- desc "Deploy to Heroku's Production Environment"
49
- task :production do
50
- ENV['ENV'] = "production"
51
- sh "git push origin master"
52
- Rake::Task["heroku_ops:deploy"].invoke
53
- end
54
-
55
- task :staging do
56
- ENV['ENV'] = "staging"
57
- sh "git push origin staging"
58
- Rake::Task["heroku_ops:deploy"].invoke
59
- end
60
-
61
- namespace :production do
62
- desc 'Quick Deploy to Production, without running migrations.'
63
- task :quick do
64
- app_name = app_name_from_environment(env)
65
- Bundler.with_clean_env do
66
- puts `git push origin master`
67
- puts `git push production master`
68
- puts `heroku restart --app app_name`
69
- end
70
- end
71
- end
72
-
73
- namespace :staging do
74
- desc 'Quick Deploy to Staging, without running migrations.'
75
- task :quick do
76
- app_name = app_name_from_environment(env)
77
- Bundler.with_clean_env do
78
- puts `git push origin staging`
79
- puts `git push staging staging:master`
80
- puts `heroku restart --app app_name`
81
- end
82
- end
83
- end
84
- end
85
- end