Skip to content

Instantly share code, notes, and snippets.

@danbt79
Last active December 11, 2015 22:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbt79/4667228 to your computer and use it in GitHub Desktop.
Save danbt79/4667228 to your computer and use it in GitHub Desktop.
# ===================================
# Capistrano Multistage Configuration
# ===================================
# 1) Let your 'config/deploy.rb' know that you're using multistage
# ===================================
# config/deploy.rb
# ===================================
set :stages, %w(staging production)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
# ===================================
# 2) Define each stage in 'config/deploy/[stage].rb'
# ===================================
# e.g. config/deploy/[production].rb
# ===================================
# Define : Environment
set :rails_env, 'production'
set :branch, 'production'
# Define : Targets & Roles
role :app, "192.168.1.1"
role :web, "192.168.1.1"
role :db, "192.168.1.1"
# Define : Endpoint
set :application, "myrailsapp.com"
set :deploy_to, "/home/user/sites/#{application}"
# Prompt our User!
# Make sure we really want to target this environment:
puts "\e[0;35m ============================\e[0m\n"
puts "\e[0;35m Really deploy to PRODUCTION?\e[0m\n"
puts "\e[0;35m ============================\e[0m\n"
# Fetch user response
response = Capistrano::CLI.ui.ask "\e[0;32m [y]es or [n]o?\e[0m\n"
# Abort if required
unless response.to_s == 'y'
puts "\e[0;31m Aborting......\e[0m\n"
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment