@@ -78,22 +78,22 @@ def copy_to_shared(cwd, release, shared_dirs, shared_files):
78
78
79
79
80
80
# DONT USE!! - todo remove
81
- def remove_resources_from_release (cwd , release , shared_dirs , shared_files ):
82
- # for directory in shared_dirs:
83
- # dir_src = cwd + '/releases/' + release + '/' + directory
84
- # if os.path.isdir(dir_src):
85
- # # clear_folder(dir_src)
86
- # run_command("rm -f " + dir_src)
87
- # else:
88
- # print("Directory does not exist to remove: {}".format(dir_src))
89
-
90
- for shared_file in shared_files :
91
- file_src = cwd + '/releases/' + release + '/' + shared_file
92
- if os .path .isfile (file_src ):
93
- run_command ("rm -f " + file_src )
94
- # os.remove(file_src)
95
- else :
96
- print ("File does not exist to remove: {}" .format (file_src ))
81
+ # def remove_resources_from_release(cwd, release, shared_dirs, shared_files):
82
+ # # for directory in shared_dirs:
83
+ # # dir_src = cwd + '/releases/' + release + '/' + directory
84
+ # # if os.path.isdir(dir_src):
85
+ # # # clear_folder(dir_src)
86
+ # # run_command("rm -f " + dir_src)
87
+ # # else:
88
+ # # print("Directory does not exist to remove: {}".format(dir_src))
89
+ #
90
+ # for shared_file in shared_files:
91
+ # file_src = cwd + '/releases/' + release + '/' + shared_file
92
+ # if os.path.isfile(file_src):
93
+ # run_command("rm -f " + file_src)
94
+ # # os.remove(file_src)
95
+ # else:
96
+ # print("File does not exist to remove: {}".format(file_src))
97
97
98
98
99
99
def run_command (my_commands ):
@@ -111,27 +111,36 @@ def run_deploy_check(cwd, new_release):
111
111
pass
112
112
113
113
114
- def run_vendors (cwd , new_release ):
114
+ def run_vendors (config , cwd , new_release ):
115
115
# Can edit this section for Laravel specific cmds
116
116
os .chdir (cwd + '/releases/' + new_release )
117
117
which_composer = subprocess .run ("which composer" , shell = True , stdout = subprocess .PIPE )
118
118
composer = which_composer .stdout .decode ('utf-8' ).rstrip ()
119
119
which_php = subprocess .run ("which php" , shell = True , stdout = subprocess .PIPE )
120
120
php = which_php .stdout .decode ('utf-8' ).rstrip ()
121
- # Install Composer libs
122
- print ("Install Composer Libs" )
123
- run_command (composer + " install --optimize-autoloader" )
124
- # Install NPM
125
- print ("Install NPM Libs" )
126
- run_command ("npm install" )
127
- run_command ("npm run production" )
128
- # Update Laravel
129
- print ("Update Laravel" )
130
- run_command (php + " artisan cache:clear" )
131
- run_command (php + " artisan route:cache" )
132
- run_command (php + " artisan config:cache" )
133
- run_command (php + " artisan view:clear" )
134
- run_command (php + " artisan queue:restart" )
121
+
122
+ if config ['install-composer-packages' ]:
123
+ # Install Composer libs
124
+ print ("Install Composer Libs" )
125
+ run_command (composer + " install --optimize-autoloader" )
126
+
127
+ if config ['install-npm-packages' ]:
128
+ # Install NPM
129
+ print ("Install NPM Libs" )
130
+ run_command ("npm install" )
131
+ run_command ("npm run production" )
132
+
133
+ if config ['laravel-clear-caches' ]:
134
+ # Laravel cache, view, route, cache reset
135
+ print ("Laravel cache, view, route, cache reset" )
136
+ run_command (php + " artisan cache:clear" )
137
+ run_command (php + " artisan view:clear" )
138
+ run_command (php + " artisan route:cache" )
139
+ run_command (php + " artisan config:cache" )
140
+
141
+ if config ['laravel-clear-caches' ]:
142
+ run_command (php + " artisan queue:restart" )
143
+
135
144
os .chdir (cwd )
136
145
137
146
@@ -170,16 +179,11 @@ def run_symlinks(cwd, new_release):
170
179
print ("Deploy is live!" )
171
180
172
181
173
- def run_post_deploy (cwd , new_release ):
174
- current_release_dir = cwd + "/releases/" + new_release
175
- os .chdir (cwd + "/current" )
176
- run_command ("php artisan config:clear" )
177
- os .chdir (cwd )
178
- # run_command("sudo chown -R $USER:www-data shared")
179
- # run_command("chmod -R 775 shared/storage")
182
+ # def run_post_deploy(cwd, new_release):
183
+ # run post deploy scripts here
180
184
181
185
182
- def run_scripts_deploy (cwd , new_release , repo , project_name , shared_dirs , shared_files , last_release ,
186
+ def run_scripts_deploy (config , cwd , new_release , repo , project_name , shared_dirs , shared_files , last_release ,
183
187
link_storage_public ):
184
188
which_git = subprocess .run ("which git" , shell = True , stdout = subprocess .PIPE )
185
189
git = which_git .stdout .decode ('utf-8' ).rstrip ()
@@ -198,11 +202,11 @@ def run_scripts_deploy(cwd, new_release, repo, project_name, shared_dirs, shared
198
202
#run_command("chown -R youruser:www-data " + cwd + '/releases/' + str(new_release))
199
203
run_command ("rm -rf " + storage_dir_src )
200
204
201
- run_vendors (cwd , new_release )
205
+ run_vendors (config , cwd , new_release )
202
206
run_deploy_check (cwd , new_release )
203
207
symlink_project_resources (cwd , shared_dirs , shared_files , new_release , link_storage_public )
204
208
run_symlinks (cwd , new_release )
205
- run_post_deploy (cwd , new_release )
209
+ # run_post_deploy(cwd, new_release)
206
210
207
211
208
212
def get_all_versions (cwd ):
0 commit comments