-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,3 @@ | |||
module CapBootstrap | module CapBootstrap | ||
VERSION = "0.3" | VERSION = "0.3.0" | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
Description: | |||
Generates a deploy.rb that works better with cap_bootstrap. | |||
Pulls application name from the Rails app name and the repository | |||
from the git config for remote origin. | |||
|
|||
Example: | |||
rails generate cap_bootstrap 255.255.255.255 | |||
|
|||
This will create: | |||
config/deploy.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
module CapBootstrap | |||
module Generators | |||
class InstallGenerator < Rails::Generators::Base | |||
source_root File.expand_path('../templates', __FILE__) | |||
argument :ip, type: :string, default: '255.255.255.255' | |||
|
|||
def generate_deploy_file | |||
template "deploy.rb", "config/deploy.rb" | |||
end | |||
|
|||
private | |||
|
|||
def application | |||
File.basename Rails.root | |||
end | |||
|
|||
def git_url | |||
default = 'git@github.com:GITHUB_USER/#{application}.git' | |||
begin | |||
git_url = `/usr/bin/env git config --get remote.origin.url`.strip | |||
rescue | |||
default | |||
end | |||
git_url.blank? ? default : git_url | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,18 @@ | |||
require "bundler/capistrano" | |||
require "cap_bootstrap/capistrano" | |||
|
|||
server "<%= ip %>", :web, :app, :db, primary: true | |||
|
|||
set :user, "deployer" | |||
set :application, "<%= application %>" | |||
set :deploy_to, "/home/#{user}/apps/#{application}" | |||
set :deploy_via, :remote_cache | |||
set :use_sudo, false | |||
set :scm, "git" | |||
set :repository, "<%= git_url %>" | |||
set :branch, "master" | |||
|
|||
default_run_options[:pty] = true | |||
ssh_options[:forward_agent] = true | |||
|
|||
after "deploy", "deploy:cleanup" # keep only the last 5 releases |