Last active
December 3, 2019 23:09
-
-
Save hussainweb/ca6601db82f7c83af017ce9a1ef0e966 to your computer and use it in GitHub Desktop.
Find out what environments can be cleared from platform.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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