deploy_docus 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/deploy_docus.rb +13 -0
- data/lib/deploy_docus/base.rb +22 -0
- data/lib/deploy_docus/config.rb +31 -0
- data/lib/deploy_docus/deployer.rb +50 -0
- data/lib/deploy_docus/version.rb +3 -0
- metadata +126 -0
data/lib/deploy_docus.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
|
4
|
+
module DeployDocus
|
5
|
+
autoload :Base, 'deploy_docus/base'
|
6
|
+
autoload :Deployer, 'deploy_docus/deployer'
|
7
|
+
autoload :Version, 'deploy_docus/version'
|
8
|
+
autoload :Config, 'deploy_docus/config'
|
9
|
+
|
10
|
+
def self.call(env)
|
11
|
+
Base.call(env)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module DeployDocus
|
4
|
+
class Base < Sinatra::Base
|
5
|
+
|
6
|
+
get '/' do
|
7
|
+
"DeployDocus"
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
post '/:application/:environment' do
|
12
|
+
config = DeployDocus::Config.new(params[:application])
|
13
|
+
deployer = DeployDocus::Deployer.new(config['repository'], "keys/#{params[:application]}", config.deploy_task(params[:environment]))
|
14
|
+
|
15
|
+
if deployer.deploy!
|
16
|
+
"OK"
|
17
|
+
else
|
18
|
+
"NOT OK"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DeployDocus
|
2
|
+
class Config
|
3
|
+
attr_accessor :application
|
4
|
+
|
5
|
+
def initialize(application)
|
6
|
+
@application = application
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](key)
|
10
|
+
config[key.to_s]
|
11
|
+
end
|
12
|
+
|
13
|
+
def deploy_task(environment)
|
14
|
+
data = self['deploy_task']
|
15
|
+
|
16
|
+
if data.is_a?(Hash)
|
17
|
+
data[environment.to_s]
|
18
|
+
else
|
19
|
+
data
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
private
|
25
|
+
def config
|
26
|
+
@config ||= YAML.load_file('config.yml')[application]
|
27
|
+
rescue
|
28
|
+
{}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'git-ssh-wrapper'
|
2
|
+
|
3
|
+
module DeployDocus
|
4
|
+
class Deployer
|
5
|
+
attr_reader :repository, :ssh_key, :deploy_task
|
6
|
+
attr_accessor :wrapper
|
7
|
+
|
8
|
+
#
|
9
|
+
# Manages cloning and deploying the repository
|
10
|
+
# This class is agnostic of any web interface and can be used as a library
|
11
|
+
#
|
12
|
+
# DeployDocus::Deployer("git@github.com:evome/evome.git", "~/.ssh/evome_key", "cap staging deploy")
|
13
|
+
#
|
14
|
+
# It will clone the repository in a random directory located in /tmp.
|
15
|
+
# And execute the deploy_task on it.
|
16
|
+
#
|
17
|
+
def initialize(repository, ssh_key, deploy_task)
|
18
|
+
@repository, @ssh_key, @deploy_task = repository, ssh_key, deploy_task
|
19
|
+
end
|
20
|
+
|
21
|
+
def deploy!
|
22
|
+
GitSSHWrapper.with_wrapper(:private_key_path => ssh_key) do |w|
|
23
|
+
wrapper = w
|
24
|
+
|
25
|
+
clone
|
26
|
+
run_deploy
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
private
|
32
|
+
def clone
|
33
|
+
puts "cloning #{repository}"
|
34
|
+
%x[#{@wrapper ? 'env ' + @wrapper.git_ssh : ''} git clone #{repository} #{tmp}]
|
35
|
+
end
|
36
|
+
|
37
|
+
def run_deploy
|
38
|
+
puts "deploying : #{deploy_task}"
|
39
|
+
%x[#{@wrapper ? 'env ' + @wrapper.git_ssh : ''} cd #{tmp}; #{deploy_task}]
|
40
|
+
end
|
41
|
+
|
42
|
+
def tmp
|
43
|
+
@tmp ||= "/tmp/#{generate_rand}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_rand
|
47
|
+
(0...8).map{65.+(rand(25)).chr}.join
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deploy_docus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Evome
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-28 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: &70175961442920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70175961442920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: minitest
|
27
|
+
requirement: &70175961442120 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70175961442120
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rack-test
|
38
|
+
requirement: &70175961441580 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70175961441580
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mocha
|
49
|
+
requirement: &70175961441040 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70175961441040
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: sinatra
|
60
|
+
requirement: &70175961440480 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70175961440480
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: &70175961439740 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.8.7
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70175961439740
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: git-ssh-wrapper
|
82
|
+
requirement: &70175961439120 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70175961439120
|
91
|
+
description: Deploy your application with a POST request
|
92
|
+
email: dev@evome.fr
|
93
|
+
executables: []
|
94
|
+
extensions: []
|
95
|
+
extra_rdoc_files: []
|
96
|
+
files:
|
97
|
+
- lib/deploy_docus.rb
|
98
|
+
- lib/deploy_docus/base.rb
|
99
|
+
- lib/deploy_docus/config.rb
|
100
|
+
- lib/deploy_docus/deployer.rb
|
101
|
+
- lib/deploy_docus/version.rb
|
102
|
+
homepage: https://github.com/evome/deploy_docus
|
103
|
+
licenses: []
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project: ! '[none]'
|
122
|
+
rubygems_version: 1.8.10
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Web interface to deploy your application
|
126
|
+
test_files: []
|