heroku_rake_deploy 0.0.1
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 +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +3 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/heroku_rake_deploy.gemspec +37 -0
- data/lib/heroku_rake_deploy/railtie.rb +5 -0
- data/lib/heroku_rake_deploy/version.rb +3 -0
- data/lib/heroku_rake_deploy.rb +8 -0
- data/lib/tasks/deploy.rake +84 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4eb873ca3982316f8b824f9c8c6523db17daed18
|
4
|
+
data.tar.gz: a7d89baf5c31f1af582014139c195339fa0a7c4b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d06846945a1bd663ba1999b8e082457c9be3f32bb6e20946f7b4ac142e53d8e51db497c5ba4a3cec1ba680d02ef56d0fa5155e9e529350388c452187226abb0
|
7
|
+
data.tar.gz: 8d8e38a2bbd0df9170a804d2b06e2630d97e5c0c88b59e7aa8cad92ba4ad1427f15824145617130d02296b1876b584bfb01a0ffcbd5840b409315e9c9e33e1a1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 nrowegt
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# HerokuRakeDeploy
|
2
|
+
|
3
|
+
A (for now) very opinionated gem which has 3 sections:
|
4
|
+
|
5
|
+
* pipeline/app setup
|
6
|
+
* db restore (pull down your heroku database and `psql < tmp/latest.db`)
|
7
|
+
* deploys (push to heroku remotes)
|
8
|
+
|
9
|
+
These tasks all assume your heroku application names are of the format `"#{Rails.application.class.parent_name.underscore.gsub('_','-')}-#{environment}"`, where environment is one of staging, production. Setting up an app includes the following free Heroku addons:
|
10
|
+
|
11
|
+
*heroku-postgresql:hobby-dev
|
12
|
+
*newrelic:wayne
|
13
|
+
*papertrail:choklad
|
14
|
+
*rediscloud:30
|
15
|
+
*scheduler:standard
|
16
|
+
*sendgrid:starter
|
17
|
+
|
18
|
+
App name configuration flags and more detailed documentation will come in a later version.
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'heroku_rake_deploy', group: :development # No need to include this on production or staging
|
27
|
+
```
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install heroku_rake_deploy
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
To see an updated list of tasks and descriptions:
|
39
|
+
`bundle exec rake heroku_rake_deploy -T heroku_rake_deploy`
|
40
|
+
|
41
|
+
~~~bash
|
42
|
+
rake db:restore # Pull Down a copy of the database from the specified heroku environment
|
43
|
+
rake db:restore:from_local_dump # Restore from local dump file (defaults to '/tmp/latest.dump' - specify with DUMP_FILE Environmental Variable)
|
44
|
+
rake db:restore:local # Erase local development and test database and restore from the local dump file
|
45
|
+
rake db:restore:production # Restore a local copy of Heroku's Production Environment database
|
46
|
+
rake db:restore:staging # Restore a local copy of Heroku's Staging Environment database
|
47
|
+
rake deploy # Deploy Safely to Heroku
|
48
|
+
rake deploy:production # Deploy to Heroku's Production Environment
|
49
|
+
rake deploy:production:quick # Quick Deploy to Production, without running migrations
|
50
|
+
rake deploy:staging:quick # Quick Deploy to Staging, without running migrations
|
51
|
+
~~~
|
52
|
+
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ldstudios/heroku_rake_deploy.
|
57
|
+
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
62
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "heroku_rake_deploy"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'heroku_rake_deploy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "heroku_rake_deploy"
|
8
|
+
spec.version = HerokuRakeDeploy::VERSION
|
9
|
+
spec.authors = ["nrowegt", "danielricecodes"]
|
10
|
+
spec.email = ["nrowegt@gmail.com", "daniel.rice@ldstudios.co"]
|
11
|
+
|
12
|
+
spec.summary = "Helpful Heroku Deploy Rake Tasks"
|
13
|
+
spec.description = "Tasks to run appllication deploys and db restores for heroku:pg databases"
|
14
|
+
spec.homepage = "https://github.com/ldstudios/heroku_rake_deploy"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "heroku_db_restore", "~> 0.0.2"
|
36
|
+
spec.add_runtime_dependency "heroku_db_restore", "~> 0.0.2"
|
37
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
|
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["deploy"].invoke
|
53
|
+
end
|
54
|
+
|
55
|
+
task :staging do
|
56
|
+
ENV['ENV'] = "staging"
|
57
|
+
sh "git push origin staging"
|
58
|
+
Rake::Task["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
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_rake_deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nrowegt
|
8
|
+
- danielricecodes
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-11-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.13'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.13'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: heroku_db_restore
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.0.2
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.0.2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: heroku_db_restore
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.0.2
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.0.2
|
70
|
+
description: Tasks to run appllication deploys and db restores for heroku:pg databases
|
71
|
+
email:
|
72
|
+
- nrowegt@gmail.com
|
73
|
+
- daniel.rice@ldstudios.co
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- heroku_rake_deploy.gemspec
|
86
|
+
- lib/heroku_rake_deploy.rb
|
87
|
+
- lib/heroku_rake_deploy/railtie.rb
|
88
|
+
- lib/heroku_rake_deploy/version.rb
|
89
|
+
- lib/tasks/deploy.rake
|
90
|
+
homepage: https://github.com/ldstudios/heroku_rake_deploy
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata:
|
94
|
+
allowed_push_host: https://rubygems.org
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.5.1
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Helpful Heroku Deploy Rake Tasks
|
115
|
+
test_files: []
|