LoginSignup
9
2

More than 3 years have passed since last update.

Google App Engine - デプロイ前に古いバージョンを削除する

Last updated at Posted at 2021-04-15

(備忘メモ)

https://cloud.google.com/appengine/docs/standard/go/an-overview-of-app-engine#limits
1アプリケーション辺りバージョン数が非課金で15、課金ありで210を超えるとデプロイが失敗する為、CI(GitHub Actions)でデプロイ前に古いバージョンを削除する。

デプロイ前に件数が30件超えていたら直近デプロイ20件を残して削除する(Traficが割り当てられるものは除く)。

↓抜粋 (※gcloudのインストールや認証は割愛)

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    steps:
    (中略)
    - name: GAE delete old versions
      run: |
          ALL_NOTRAFIC_VERSIONS=$(gcloud app versions list --format="value(id)" --service=your_service --filter="traffic_split=0" --sort-by="~lastDeployedTime" --project=your_project)
          if test "$(echo "$ALL_NOTRAFIC_VERSIONS" | wc -l)" -gt 30; then
              DELETING_VERSIONS=$(echo "$ALL_NOTRAFIC_VERSIONS" |tail -n +21)
              gcloud app versions delete --quiet --project=your_project --service=your_service $(echo "$DELETING_VERSIONS")
          fi
9
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
2