Created
February 4, 2019 23:27
-
-
Save pestilence669/d29ec9dd591d583e081bafd262594c65 to your computer and use it in GitHub Desktop.
Delete old deployed versions on Google App Engine
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 | |
# vim: set ts=4 sw=4 noet fileencoding=utf-8: | |
readonly SERVICE=${1-api} | |
readonly versions=$(gcloud app versions list --service=$SERVICE \ | |
--sort-by=~version.createTime \ | |
--format='table[no-heading](id)') | |
declare -i KEEP_LAST=${KEEP_LAST-5} | |
declare -i c=0 | |
for version in $versions; do | |
((++c)) | |
if [[ $c -gt $KEEP_LAST ]]; then | |
gcloud versions delete --service $SERVICE --version $version | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment