-
-
Save fcoclavero/2f4d3e5f7c7a5b3f070b5a5a48d019d3 to your computer and use it in GitHub Desktop.
Remove old versions of Google App Engine with GitHub Actions
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
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