From aaa06f41207ee5d7f2efb739c44a064c67e5c8cd Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 29 May 2024 11:17:16 +0200 Subject: [PATCH] fix: build server dirs not created on main server --- app/Jobs/ApplicationDeploymentJob.php | 106 +++++++++++++++----------- 1 file changed, 60 insertions(+), 46 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 4fe1ccda9..bc109abc6 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -817,16 +817,29 @@ private function save_environment_variables() $this->env_filename = null; if ($this->use_build_server) { $this->server = $this->original_server; - } - $this->execute_remote_command( - [ - "command" => "rm -f $this->configuration_dir/{$this->env_filename}", - "hidden" => true, - "ignore_errors" => true - ] - ); - if ($this->use_build_server) { + $this->execute_remote_command( + [ + "command" => "rm -f $this->configuration_dir/{$this->env_filename}", + "hidden" => true, + "ignore_errors" => true + ] + ); $this->server = $this->build_server; + $this->execute_remote_command( + [ + "command" => "rm -f $this->configuration_dir/{$this->env_filename}", + "hidden" => true, + "ignore_errors" => true + ] + ); + } else { + $this->execute_remote_command( + [ + "command" => "rm -f $this->configuration_dir/{$this->env_filename}", + "hidden" => true, + "ignore_errors" => true + ] + ); } } else { $envs_base64 = base64_encode($envs->implode("\n")); @@ -838,38 +851,21 @@ private function save_environment_variables() ); if ($this->use_build_server) { $this->server = $this->original_server; - } - $this->execute_remote_command( - [ - "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null" - ] - ); - if ($this->use_build_server) { + $this->execute_remote_command( + [ + "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null" + ] + ); $this->server = $this->build_server; + } else { + $this->execute_remote_command( + [ + "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null" + ] + ); } - } - // $this->execute_remote_command([ - // executeInDocker($this->deployment_uuid, "cat $this->workdir/.env 2>/dev/null || true"), - // "hidden" => true, - // "save" => "dotenv" - // ]); - // if (str($this->saved_outputs->get('dotenv'))->isNotEmpty()) { - // $base64_dotenv = base64_encode($this->saved_outputs->get('dotenv')->value()); - // $this->execute_remote_command( - // [ - // "echo '{$base64_dotenv}' | base64 -d | tee $this->configuration_dir/.env > /dev/null" - // ] - // ); - // } else { - // $this->execute_remote_command( - // [ - // "command" => "rm -f $this->configuration_dir/.env", - // "hidden" => true, - // "ignore_errors" => true - // ] - // ); - // } + } } @@ -1052,14 +1048,32 @@ private function deploy_pull_request() } private function create_workdir() { - $this->execute_remote_command( - [ - "command" => executeInDocker($this->deployment_uuid, "mkdir -p {$this->workdir}") - ], - [ - "command" => "mkdir -p {$this->configuration_dir}" - ], - ); + if ($this->use_build_server) { + $this->server = $this->original_server; + $this->execute_remote_command( + [ + "command" => "mkdir -p {$this->configuration_dir}" + ], + ); + $this->server = $this->build_server; + $this->execute_remote_command( + [ + "command" => executeInDocker($this->deployment_uuid, "mkdir -p {$this->workdir}") + ], + [ + "command" => "mkdir -p {$this->configuration_dir}" + ], + ); + } else { + $this->execute_remote_command( + [ + "command" => executeInDocker($this->deployment_uuid, "mkdir -p {$this->workdir}") + ], + [ + "command" => "mkdir -p {$this->configuration_dir}" + ], + ); + } } private function prepare_builder_image() {