git-deploy 0.5.5 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +19 -1
- data/lib/git_deploy.rb +23 -4
- data/lib/git_deploy/ssh_methods.rb +5 -2
- data/lib/hooks/post-receive.sh +5 -2
- metadata +2 -2
data/README.markdown
CHANGED
@@ -101,16 +101,34 @@ repository. This is how your code on the server is kept up to date. This script
|
|
101
101
|
checks out the latest version of your project from the current branch and
|
102
102
|
runs the following callback scripts:
|
103
103
|
|
104
|
+
* `deploy/setup` - on first push.
|
104
105
|
* `deploy/after_push` - on subsequent pushes. It in turn executes:
|
105
106
|
* `deploy/before_restart`
|
106
107
|
* `deploy/restart`
|
107
108
|
* `deploy/after_restart`
|
109
|
+
* `deploy/rollback` - executed for `git deploy rollback`.
|
108
110
|
|
109
111
|
All of the callbacks are optional. These scripts are ordinary Unix executables.
|
110
112
|
The ones which get generated for you by `git deploy init` are written in shell
|
111
113
|
script and Ruby.
|
112
114
|
|
113
|
-
|
115
|
+
|
116
|
+
Extra commands
|
117
|
+
--------------
|
118
|
+
|
119
|
+
* `git deploy hooks` - Updates git hooks on the remote repository
|
120
|
+
|
121
|
+
* `git deploy log [N=20]` - Shows last 20 lines of deploy log on the server
|
122
|
+
|
123
|
+
* `git deploy rerun` - Re-runs the `deploy/after_push` callback as if a git push happened
|
124
|
+
|
125
|
+
* `git deploy restart` - Runs the `deploy/restart` callback
|
126
|
+
|
127
|
+
* `git deploy rollback` - Undo a deploy by checking out the previous revision,
|
128
|
+
runs `deploy/callback` if exists instead of `deploy/after_push`
|
129
|
+
|
130
|
+
* `git deploy upload <files>` - Copy local files to the remote app
|
131
|
+
|
114
132
|
|
115
133
|
|
116
134
|
[heroku]: http://heroku.com/
|
data/lib/git_deploy.rb
CHANGED
@@ -20,8 +20,8 @@ class GitDeploy < Thor
|
|
20
20
|
end
|
21
21
|
|
22
22
|
desc "setup", "Create the remote git repository and install push hooks for it"
|
23
|
-
method_option :shared, :aliases => '-g', :type => :boolean, :default =>
|
24
|
-
method_option :sudo, :aliases => '-s', :type => :boolean, :default =>
|
23
|
+
method_option :shared, :aliases => '-g', :type => :boolean, :default => false
|
24
|
+
method_option :sudo, :aliases => '-s', :type => :boolean, :default => false
|
25
25
|
def setup
|
26
26
|
sudo = options.sudo? ? "#{sudo_cmd} " : ''
|
27
27
|
|
@@ -58,10 +58,29 @@ class GitDeploy < Thor
|
|
58
58
|
run "cd #{deploy_to} && deploy/restart 2>&1 | tee -a log/deploy.log"
|
59
59
|
end
|
60
60
|
|
61
|
+
desc "rerun", "Runs the `deploy/after_push' callback as if a new revision was pushed via git"
|
62
|
+
def rerun
|
63
|
+
run <<-BASH, :echo => false
|
64
|
+
bash -e -c '
|
65
|
+
cd '#{deploy_to}'
|
66
|
+
declare -a revs=( $(git rev-parse HEAD@{1} HEAD) )
|
67
|
+
deploy/after_push ${revs[@]} 2>&1 | tee -a log/deploy.log
|
68
|
+
'
|
69
|
+
BASH
|
70
|
+
end
|
71
|
+
|
61
72
|
desc "rollback", "Rolls back the checkout to before the last push"
|
62
73
|
def rollback
|
63
|
-
run
|
64
|
-
|
74
|
+
run <<-BASH, :echo => false
|
75
|
+
bash -e -c '
|
76
|
+
cd '#{deploy_to}'
|
77
|
+
declare -a revs=( $(git rev-parse HEAD HEAD@{1}) )
|
78
|
+
git reset --hard ${revs[1]}
|
79
|
+
callback=after_push
|
80
|
+
[ -x deploy/rollback ] && callback=rollback
|
81
|
+
deploy/$callback ${revs[@]} 2>&1 | tee -a log/deploy.log
|
82
|
+
'
|
83
|
+
BASH
|
65
84
|
end
|
66
85
|
|
67
86
|
desc "log", "Shows the last part of the deploy log on the server"
|
@@ -11,10 +11,13 @@ class GitDeploy
|
|
11
11
|
super unless options.noop?
|
12
12
|
end
|
13
13
|
|
14
|
-
def run(cmd = nil)
|
14
|
+
def run(cmd = nil, opt = {})
|
15
15
|
cmd = yield(cmd) if block_given?
|
16
16
|
cmd = cmd.join(' && ') if Array === cmd
|
17
|
-
|
17
|
+
|
18
|
+
if opt.fetch(:echo, true)
|
19
|
+
puts "[#{options[:remote]}] $ " + cmd.gsub(' && ', " && \\\n ")
|
20
|
+
end
|
18
21
|
|
19
22
|
unless options.noop?
|
20
23
|
status, output = ssh_exec cmd do |ch, stream, data|
|
data/lib/hooks/post-receive.sh
CHANGED
@@ -43,10 +43,13 @@ if [ -z "${oldrev//0}" ]; then
|
|
43
43
|
|
44
44
|
# init submodules
|
45
45
|
git submodule update --recursive --init 2>&1 | tee -a $logfile
|
46
|
+
|
47
|
+
# execute the one-time setup hook
|
48
|
+
[ -x deploy/setup ] && deploy/setup $oldrev $newrev 2>&1 | tee -a $logfile
|
46
49
|
else
|
47
50
|
# log timestamp
|
48
51
|
echo ==== $(date) ==== >> $logfile
|
49
52
|
|
50
|
-
# execute the deploy hook
|
51
|
-
[ -x deploy/after_push ] &&
|
53
|
+
# execute the main deploy hook
|
54
|
+
[ -x deploy/after_push ] && deploy/after_push $oldrev $newrev 2>&1 | tee -a $logfile
|
52
55
|
fi
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: git-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.6.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mislav Marohnić
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|