Skip to content

Instantly share code, notes, and snippets.

@spark2ignite
Created February 21, 2018 21:09
Show Gist options
  • Save spark2ignite/75613f590a24244356472b1e06eac4df to your computer and use it in GitHub Desktop.
Save spark2ignite/75613f590a24244356472b1e06eac4df to your computer and use it in GitHub Desktop.
#!/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