Skip to content

Instantly share code, notes, and snippets.

@Kolin
Last active November 9, 2017 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kolin/0cae37f7e4733fd798ac91ed2001202f to your computer and use it in GitHub Desktop.
Save Kolin/0cae37f7e4733fd798ac91ed2001202f to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
use Platformsh\Client\PlatformClient;
if (!empty($_ENV['PLATFORM_ENVIRONMENT'])) {
$env_variables = json_decode(base64_decode($_ENV['PLATFORM_VARIABLES']));
$client = new PlatformClient();
$token = $env_variables->deploy_token;
$client->getConnector()->setApiToken($token, 'exchange');
$projects = $client->getProjects();
if ($projects) {
$project = reset($projects);
foreach ($project->getEnvironments() as $environment) {
if ($environment->machine_name === $_ENV['PLATFORM_ENVIRONMENT']) {
if ((bool) $environment->getVariable('re_deploy')->value === FALSE) {
$environment->setVariable('re_deploy', 'TRUE');
}
else {
$environment->setVariable('re_deploy', 'FALSE');
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment