Created
February 21, 2018 21:09
-
-
Save spark2ignite/75613f590a24244356472b1e06eac4df to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
VERSIONS=$(gcloud app versions list --service $1 --sort-by '~version' --format 'value(version.id)') | |
COUNT=0 | |
echo "Keeping the $2 latest versions of the $1 service" | |
for VERSION in $VERSIONS | |
do | |
((COUNT++)) | |
if [ $COUNT -gt $2 ] | |
then | |
echo "Going to delete version $VERSION of the $1 service." | |
gcloud app versions delete $VERSION --service $1 -q | |
else | |
echo "Going to keep version $VERSION of the $1 service." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment