From 3a693d3bc1680826fe8ca73c8b48dbc4ebaf8872 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Fri, 20 Oct 2023 16:41:39 +0100 Subject: [PATCH 1/4] update deployment output --- src/Commands/Output/DeploymentSuccess.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Commands/Output/DeploymentSuccess.php b/src/Commands/Output/DeploymentSuccess.php index 99dc73e7..6250f621 100644 --- a/src/Commands/Output/DeploymentSuccess.php +++ b/src/Commands/Output/DeploymentSuccess.php @@ -54,11 +54,17 @@ protected function displayDnsRecordsChanges(Deployment $deployment) Helpers::line(); } + $records = collect($deployment->regions)->map(function ($region) { + return collect($region['pivot']['target_domains'])->map(function ($target, $domain) use ($region) { + return [$region['region'], $domain, $target['domain']]; + })->values(); + })->flatten(1)->merge(collect($deployment->target_domains)->map(function ($target, $domain) use ($deployment) { + return [$deployment->project['region'], $domain, $target['domain']]; + })->values()); + Helpers::table([ - 'Domain', 'Alias / CNAME', - ], collect($deployment->target_domains)->map(function ($target, $domain) { - return [$domain, $target['domain']]; - })->all()); + 'Region', 'Domain', 'Alias / CNAME', + ], $records->all()); $vapor = Helpers::app(ConsoleVaporClient::class); From ea2856f09352f4b7b29b2f0bcbfbedd6db931ebf Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 1 Nov 2023 15:36:08 +0000 Subject: [PATCH 2/4] send regions --- src/Commands/DeployCommand.php | 16 ++++++++++++++++ src/ConsoleVaporClient.php | 3 +++ src/Manifest.php | 13 +++++++++++++ 3 files changed, 32 insertions(+) diff --git a/src/Commands/DeployCommand.php b/src/Commands/DeployCommand.php index 49712bb6..a8502f7e 100644 --- a/src/Commands/DeployCommand.php +++ b/src/Commands/DeployCommand.php @@ -199,6 +199,7 @@ protected function uploadArtifact($environment, $uuid) Manifest::id(), $uuid, $environment, + Manifest::regions($environment), Manifest::usesContainerImage($environment) ? null : Path::artifact(), $this->option('commit') ?: Git::hash(), $this->option('message') ?: Git::message(), @@ -227,6 +228,21 @@ protected function uploadArtifact($environment, $uuid) $artifact['container_registry_token'], $artifact['container_repository'], $artifact['container_image_tag']); + + foreach (Manifest::current()['environments'][$environment]['regions'] ?? [] as $region) + { + Helpers::step('Pushing Container Image to '.$region.''); + + Docker::publish( + Path::app(), + Manifest::name(), + $environment, + $artifact['container_registry_token'], + $artifact['container_repository'], + $artifact['container_image_tag'], + $region + ); + } } return $artifact; diff --git a/src/ConsoleVaporClient.php b/src/ConsoleVaporClient.php index 3ac7d025..6138f434 100644 --- a/src/ConsoleVaporClient.php +++ b/src/ConsoleVaporClient.php @@ -1002,6 +1002,7 @@ public function deleteSecret($secretId) * @param int $projectId * @param string $uuid * @param string $environment + * @param array $regions * @param string $file * @param string $commit * @param string $commitMessage @@ -1014,6 +1015,7 @@ public function createArtifact( $projectId, $uuid, $environment, + $regions, $file = null, $commit = null, $commitMessage = null, @@ -1029,6 +1031,7 @@ public function createArtifact( 'cli_version' => $cliVersion, 'core_version' => $coreVersion, 'uses_container_image' => is_null($file), + 'regions' => $regions, ]); if ($file) { diff --git a/src/Manifest.php b/src/Manifest.php index 719afd26..e6ed829c 100644 --- a/src/Manifest.php +++ b/src/Manifest.php @@ -34,6 +34,19 @@ public static function name() return static::current()['name']; } + /** + * Get the regions from the current directory's manifest. + * + * @param string $environment + * @return array + */ + public static function regions($environment) + { + return array_key_exists('regions', static::current()['environments'][$environment]) + ? static::current()['environments'][$environment]['regions'] + : []; + } + /** * Retrieve the manifest for the current working directory. * From 47b7f6b99c4df8ba7178cbf3e3afdd7425fc1241 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 1 Nov 2023 15:36:36 +0000 Subject: [PATCH 3/4] push image once --- src/Commands/DeployCommand.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Commands/DeployCommand.php b/src/Commands/DeployCommand.php index a8502f7e..47322de3 100644 --- a/src/Commands/DeployCommand.php +++ b/src/Commands/DeployCommand.php @@ -228,21 +228,6 @@ protected function uploadArtifact($environment, $uuid) $artifact['container_registry_token'], $artifact['container_repository'], $artifact['container_image_tag']); - - foreach (Manifest::current()['environments'][$environment]['regions'] ?? [] as $region) - { - Helpers::step('Pushing Container Image to '.$region.''); - - Docker::publish( - Path::app(), - Manifest::name(), - $environment, - $artifact['container_registry_token'], - $artifact['container_repository'], - $artifact['container_image_tag'], - $region - ); - } } return $artifact; From 6bafa9fd7dfe03d2827216651b98c175da757ced Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 1 Nov 2023 15:36:56 +0000 Subject: [PATCH 4/4] Apply fixes from StyleCI --- src/ConsoleVaporClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ConsoleVaporClient.php b/src/ConsoleVaporClient.php index 6138f434..8357687a 100644 --- a/src/ConsoleVaporClient.php +++ b/src/ConsoleVaporClient.php @@ -1002,7 +1002,7 @@ public function deleteSecret($secretId) * @param int $projectId * @param string $uuid * @param string $environment - * @param array $regions + * @param array $regions * @param string $file * @param string $commit * @param string $commitMessage