go-deploy 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/go_deploy/deploy.rb +24 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c9672f6908faee5f19501db53af7230be2f274e0ccb5469e407ddd71a1a47b3
|
4
|
+
data.tar.gz: 7f9cb32b9d55e8ec777d51bae3b90d69b6f8e9d3f3d5afacd0848712f69dcde8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae6cfd9afe3650118edf1537f72a923631ea3bf6444c876eaf8dc033e3db8563897611c6f0450ad6eff2485d9c1f6a855149d7efa7fd46f873362912e338aaa0
|
7
|
+
data.tar.gz: 976a2416b7282221a11b9e6e3a73a5a67218092a7bb992aabbb77ed34fbbb6298af71100b27e4c1d98906d976b7b99df93a65e2d79e73072b52df41ca52ea003
|
data/lib/go_deploy/deploy.rb
CHANGED
@@ -64,14 +64,16 @@ module GoDeploy
|
|
64
64
|
# Step 3
|
65
65
|
git_clone
|
66
66
|
# Step 4
|
67
|
-
|
67
|
+
git_update
|
68
68
|
# Step 5
|
69
|
+
set_env
|
70
|
+
# Step 6
|
69
71
|
build_go
|
70
|
-
# Stop 6
|
71
|
-
copy_files
|
72
72
|
# Stop 7
|
73
|
-
|
73
|
+
copy_files
|
74
74
|
# Stop 8
|
75
|
+
remove_files
|
76
|
+
# Stop 9
|
75
77
|
start_go_service if @is_restart
|
76
78
|
end
|
77
79
|
|
@@ -93,31 +95,38 @@ module GoDeploy
|
|
93
95
|
end
|
94
96
|
|
95
97
|
def git_check
|
98
|
+
@git_repo_url = @service['git_repo_url']
|
96
99
|
puts 'Step 2 git:check'.green
|
97
|
-
@console.exec(ssh: ssh, command: "git ls-remote #{@
|
100
|
+
@console.exec(ssh: ssh, command: "git ls-remote #{@git_repo_url} HEAD")
|
98
101
|
end
|
99
102
|
|
100
103
|
def git_clone
|
101
104
|
@deploy_to = @service['deploy_to']
|
102
105
|
puts 'Step 3 git:clone'.green
|
103
106
|
@console.exec(ssh: ssh, command: "mkdir -p #{@deploy_to}")
|
104
|
-
@console.exec(ssh: ssh, command: "git clone #{@
|
107
|
+
@console.exec(ssh: ssh, command: "git clone #{@git_repo_url} #{@deploy_to}/repo")
|
105
108
|
# clean up files
|
106
109
|
@service['copy_files'].each do |file_name|
|
107
110
|
@console.exec(ssh: ssh, command: "rm -rf #{@deploy_to}/#{file_name}")
|
108
111
|
end
|
109
112
|
end
|
110
113
|
|
114
|
+
def git_update
|
115
|
+
puts 'Step 4 git:clone'.green
|
116
|
+
@console.exec(ssh: ssh, command: "cd #{@deploy_to}/repo && git remote set-url origin #{@git_repo_url}")
|
117
|
+
@console.exec(ssh: ssh, command: "cd #{@deploy_to}/repo && git remote update --prune")
|
118
|
+
end
|
119
|
+
|
111
120
|
def set_env
|
112
|
-
|
121
|
+
@deploy_env_file = "#{@deploy_to}/repo/.env"
|
113
122
|
@env_file = @service['env_file']
|
114
|
-
puts 'Step
|
115
|
-
@console.log(command: "Uploading #{
|
123
|
+
puts 'Step 5 set:env'.green
|
124
|
+
@console.log(command: "Uploading #{@deploy_env_file}") if ssh.scp.upload!(@env_file, @deploy_env_file)
|
116
125
|
end
|
117
126
|
|
118
127
|
def build_go
|
119
128
|
@service_name = @service['name']
|
120
|
-
puts 'Step
|
129
|
+
puts 'Step 6 build:go'.green
|
121
130
|
@is_restart = @service['is_restart']
|
122
131
|
|
123
132
|
if @is_restart
|
@@ -125,13 +134,12 @@ module GoDeploy
|
|
125
134
|
puts "\tStop #{@service_name} service".green
|
126
135
|
end
|
127
136
|
|
128
|
-
@console.exec(ssh: ssh, command: "cd #{@
|
137
|
+
@console.exec(ssh: ssh, command: "cd #{@deploy_to}/repo && go build -o #{@service_name}")
|
129
138
|
end
|
130
139
|
|
131
140
|
def copy_files
|
132
|
-
puts 'Step
|
133
|
-
@
|
134
|
-
@console.exec(ssh: ssh, command: "cd #{@deploy_to}/repo && mv .env #{@deploy_to}")
|
141
|
+
puts 'Step 7 copy files'.green
|
142
|
+
@console.exec(ssh: ssh, command: "cd #{@deploy_to}/repo && mv #{@deploy_env_file} #{@deploy_to}")
|
135
143
|
|
136
144
|
@service['copy_files'].each do |file_name|
|
137
145
|
@console.exec(ssh: ssh, command: "cd #{@deploy_to}/repo && mv #{file_name} #{@deploy_to}")
|
@@ -141,7 +149,7 @@ module GoDeploy
|
|
141
149
|
end
|
142
150
|
|
143
151
|
def remove_files
|
144
|
-
puts 'Step
|
152
|
+
puts 'Step 8 removed:files'.green
|
145
153
|
@console.exec(ssh: ssh, command: "cd #{@deploy_to}/repo && mv #{@service_name} #{@deploy_to}")
|
146
154
|
@console.exec(ssh: ssh, command: "rm -rf #{@deploy_to}/repo")
|
147
155
|
@console.exec(ssh: ssh, command: "rm -rf #{@git_wrapper_path}")
|
@@ -149,7 +157,7 @@ module GoDeploy
|
|
149
157
|
end
|
150
158
|
|
151
159
|
def start_go_service
|
152
|
-
puts "Step
|
160
|
+
puts "Step 9 systemctl:start:#{@service_name}".green
|
153
161
|
@console.sudo_exec(ssh: ssh, command: "sudo systemctl start #{@service_name}.service")
|
154
162
|
puts "\tStart #{@service_name} service".green
|
155
163
|
end
|