diff --git a/.github/workflows/gar-cleanup.yml b/.github/workflows/gar-cleanup.yml deleted file mode 100644 index 1f4bc62..0000000 --- a/.github/workflows/gar-cleanup.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: GAR Cleanup - -on: - schedule: - - cron: '30 6 * * *' - workflow_dispatch: {} - workflow_run: - workflows: ['Deploy'] - types: - - completed - -jobs: - docker_cleanup: - name: Cleanup Deployed Images - runs-on: ubuntu-latest - strategy: - matrix: - region: [us, europe, asia] - fail-fast: false - steps: - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@master - with: - project_id: ${{ secrets.GCS_PROJECT_ID }} - service_account_key: ${{ secrets.GCS_TF_KEY }} - export_default_credentials: true - - - name: Delete stale artifacts - run: | - flags="--format=json --location=${{matrix.region}} --repository=roleypoly" - - packagesToPrune=$(gcloud artifacts packages list $flags | jq -r '.[].name') - - for package in $packagesToPrune; do - tagsToKeep=$(gcloud artifacts tags list --package=$package $flags | jq -r '.[].version') - versionsToCheck=$(gcloud artifacts versions list --package=$package $flags | jq -r '.[].name') - - for version in $versionsToCheck; do - if [[ "$tagsToKeep" =~ .*"$version".* ]]; then - continue - fi - - gcloud artifacts versions delete $version --package=$package $flags --quiet - done - done