Skip to content

Instantly share code, notes, and snippets.

@hussainweb
Last active December 3, 2019 23:09
Show Gist options
  • Save hussainweb/ca6601db82f7c83af017ce9a1ef0e966 to your computer and use it in GitHub Desktop.
Save hussainweb/ca6601db82f7c83af017ce9a1ef0e966 to your computer and use it in GitHub Desktop.
Find out what environments can be cleared from platform.sh
#!/usr/bin/env php
<?php
$environments = explode("\n", `platform environments --columns=title,status --format=tsv --no-header | grep -v "\tInactive" | awk "{print \\$1}"`);
$remote_branches = explode("\n", `git ls-remote --heads | awk "{ print \\$2 }" | sed 's/refs\\/heads\\///'`);
$environments = \array_diff($environments, [
"Master",
"develop",
"qa",
"uat",
], $remote_branches);
echo "platform environment:delete -y " . implode(" ", $environments);
echo "; platform environment:delete --inactive -y\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment