How to automatically delete old Google App Engine version instances?

后端 未结 6 1121
囚心锁ツ
囚心锁ツ 2021-02-12 10:57

I\'m experimenting with more cost effective ways to deploy my Rails apps, and went through the Ruby Starter Projects to get a feel for Google Cloud Platform.

It\'s al

6条回答
  •  青春惊慌失措
    2021-02-12 11:18

    We deploy an App Engine instance from Cloud Build, which is a common deployment pattern. At the end of the cloudbuild.yaml, we specify the following commands, which deletes every version except the last 5 versions:

    versions=$(gcloud app versions list \
      --service default \
      --sort-by '~version' \
      --format 'value(VERSION.ID)' | sed 1,5d)
    for version in $versions; do
      gcloud app versions delete "$version" \
        --service default \
        --quiet
    done
    

提交回复
热议问题