Last active
August 23, 2024 09:15
-
-
Save qlawmarq/db7d352e5200b5bfc5a26eac0553ee5f to your computer and use it in GitHub Desktop.
Remove old versions of Google App Engine with GitHub Actions
This file contains hidden or 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
name: Remove old versions of Google App Engine | |
##### | |
# | |
# Add this file to .github/workflows/delete-old-gae.yml then GitHub Actions will remove old versions of Google App Engine. | |
# | |
##### | |
on: | |
workflow_dispatch: | |
schedule: [{ cron: '0 0 * * *' }] | |
jobs: | |
remove-old-versions: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Cloud Auth | |
uses: google-github-actions/auth@v0 | |
with: | |
# You need to add GCP_CREDENTIALS to your GitHub secrets: | |
# cat your-service-key.json | base64 | pbcopy | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v0 | |
- name: Remove old versions of Google App Engine | |
env: | |
CI: true | |
# Set your project id here. | |
PROJECT_ID: your-project-2023 | |
# Delete only the 30th and older version IDs | |
run: gcloud app versions list --project ${PROJECT_ID} --format 'value(version.id)' --sort-by '~version' | tail -n +30 | xargs --no-run-if-empty gcloud app versions delete --project ${PROJECT_ID} --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment