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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/go_deploy/deploy.rb +24 -16
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c385399badbee84ad7c506aa7b4655d4a8dbd24cd48a430e5942162b6ff27ae
4
- data.tar.gz: e564f308ced04af90337ea9c1d8cb70745bb45afc9fbcf0fdd9bb8afc9683354
3
+ metadata.gz: 5c9672f6908faee5f19501db53af7230be2f274e0ccb5469e407ddd71a1a47b3
4
+ data.tar.gz: 7f9cb32b9d55e8ec777d51bae3b90d69b6f8e9d3f3d5afacd0848712f69dcde8
5
5
  SHA512:
6
- metadata.gz: 2219a8c491e77b8160b5185100c1fb9450f1f1ae8b78201fba5cc0e6811f1340c0b8cc9b957a8239d96fbb96bb120a604193e381c50dcc5968666cf95c0e616f
7
- data.tar.gz: '08b60e0511abd792efb684c3c988a8137111b771153238df31dd0a9d1b9889a8dbbd93188da54d4198674d27eb9b69d6312ec6072b6561e9ee204d1658f7681f'
6
+ metadata.gz: ae6cfd9afe3650118edf1537f72a923631ea3bf6444c876eaf8dc033e3db8563897611c6f0450ad6eff2485d9c1f6a855149d7efa7fd46f873362912e338aaa0
7
+ data.tar.gz: 976a2416b7282221a11b9e6e3a73a5a67218092a7bb992aabbb77ed34fbbb6298af71100b27e4c1d98906d976b7b99df93a65e2d79e73072b52df41ca52ea003
@@ -64,14 +64,16 @@ module GoDeploy
64
64
  # Step 3
65
65
  git_clone
66
66
  # Step 4
67
- set_env
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
- remove_files
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 #{@service['git_repo_url']} HEAD")
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 #{@service['git_repo_url']} #{@deploy_to}/repo")
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
- project_env_file = "#{@deploy_to}/repo/.env"
121
+ @deploy_env_file = "#{@deploy_to}/repo/.env"
113
122
  @env_file = @service['env_file']
114
- puts 'Step 4 set:env'.green
115
- @console.log(command: "Uploading #{project_env_file}") if ssh.scp.upload!(@env_file, project_env_file)
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 5 build:go'.green
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 #{@service['deploy_to']}/repo && go build -o #{@service_name}")
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 6 copy files'.green
133
- @service_name = @service['name']
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 7 removed:files'.green
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 8 systemctl:start:#{@service_name}".green
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saharak Manoo