diff --git a/php/Terminus/Environment.php b/php/Terminus/Environment.php index 862e4720d..81f92e9c9 100755 --- a/php/Terminus/Environment.php +++ b/php/Terminus/Environment.php @@ -388,21 +388,13 @@ private function element_as_database($element) { } /** - * Deploys the given environment + * Deploys the Test or Live environment) * - * @param [array] $args Arguments for deployment - * [string] $args['from'] Environment from which to deploy - * [string] $args['annotation'] Commit message - * @return [array] Data from the request + * @param [array] $params Parameters for the deploy workflow + * + * @return [workflow] workflow response */ - public function deploy($args) { - $default_params = array( - 'annotation' => 'Terminus deploy', - 'clone_database' => array('from_environment' => 'dev'), - 'clone_files' => array('from_environment' => 'dev'), - ); - $params = array_merge($default_params, $args); - + public function deploy($params) { $workflow = $this->site->workflows->create('deploy', array( 'environment' => $this->id, 'params' => $params diff --git a/php/Terminus/Site.php b/php/Terminus/Site.php index 6c14db6cd..b4499221b 100755 --- a/php/Terminus/Site.php +++ b/php/Terminus/Site.php @@ -323,11 +323,6 @@ public function removeInstrument() { return $workflow; } - /** - * Returns the environment's name - * - } - /** * Create a multidev environment */ diff --git a/php/commands/site.php b/php/commands/site.php index cd4a99d66..a5c3bb758 100755 --- a/php/commands/site.php +++ b/php/commands/site.php @@ -781,10 +781,13 @@ public function delete_env($args, $assoc_args) { * : Site to deploy from * * [--env=] - * : Environment to deploy to + * : Environment to be deployed (Test or Live) + * + * [--clone-live-content] + * : If deploying test, copy content from Live * * [--from=] - * : Environment to deploy from + * : [deprecated] Environment to deploy from (non-functional) * * [--cc] * : Clear cache after deploy? @@ -803,11 +806,9 @@ public function deploy($args, $assoc_args) { 'env', 'Choose environment to deploy' )); - $from = Input::env( - $assoc_args, - 'from', - 'Choose environment you want to deploy from' - ); + + $clone_live_content = ($env->id == 'test' && isset($assoc_args['clone-live-content'])); + if(!isset($assoc_args['note'])) { $annotation = Terminus::prompt( 'Custom note for the deploy log', @@ -824,10 +825,13 @@ public function deploy($args, $assoc_args) { 'updatedb' => $updatedb, 'clear_cache' => $cc, 'annotation' => $annotation, - 'clone_database' => array('from_environment' => $from), - 'clone_files' => array('from_environment' => $from), ); + if ($clone_live_content) { + $params['clone_database'] = array('from_environment' => 'live'); + $params['clone_files'] = array('from_environment' => 'live'); + } + $workflow = $env->deploy($params); $workflow->wait(); diff --git a/tests/features/deploy.feature b/tests/features/deploy.feature index d314fcfcb..cb2663e62 100644 --- a/tests/features/deploy.feature +++ b/tests/features/deploy.feature @@ -4,5 +4,5 @@ Feature: Deploy @vcr site-deploy Given I am authenticated And a site named "[[test_site_name]]" - When I run "terminus site deploy --site=[[test_site_name]] --from=dev --env=test --note='Deploy test'" + When I run "terminus site deploy --site=[[test_site_name]] --env=test --clone-live-content --note='Deploy test'" Then I should get "Woot! Code deployed to test" diff --git a/tests/fixtures/site-deploy b/tests/fixtures/site-deploy index 42038f698..b2bd5e931 100644 --- a/tests/fixtures/site-deploy +++ b/tests/fixtures/site-deploy @@ -227,7 +227,7 @@ User-Agent: 'Terminus/1.0.0 (php_version=5.5.26&script=boot-fs.php)' Cookie: 'X-Pantheon-Session=25069e79-eae7-4d41-8925-1f728a114cb8:50d069c4-3ae4-11e5-97ba-bc764e117665:XdwFVyCuTDtq4km6jNjnT' Content-type: application/json - body: '{"type":"deploy","params":{"annotation":"Deploy test","clone_database":{"from_environment":"dev"},"clone_files":{"from_environment":"dev"},"updatedb":0,"clear_cache":0}}' + body: '{"type":"deploy","params":{"updatedb":0,"clear_cache":0,"annotation":"Deploy test","clone_database":{"from_environment":"live"},"clone_files":{"from_environment":"live"}}}' response: status: http_version: '1.1'