From 00708278002f75ff6df7a7a3a9a1c5c6911024bc Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Fri, 6 Sep 2024 14:54:24 -0400 Subject: [PATCH] simplify deleting cache Signed-off-by: Alex Goodman --- .github/workflows/validations.yaml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/validations.yaml b/.github/workflows/validations.yaml index 709e1bfe972..f41fcfe14b5 100644 --- a/.github/workflows/validations.yaml +++ b/.github/workflows/validations.yaml @@ -208,22 +208,14 @@ jobs: name: "Cleanup snapshot cache" if: always() runs-on: ubuntu-20.04 + permissions: + actions: write needs: - Acceptance-Linux - Acceptance-Mac - Cli-Linux steps: - name: Delete snapshot cache - run: | - # Define the cache key to delete - CACHE_KEY="snapshot-build-${{ github.run_id }}" - - # Fetch cache list and delete the cache by key using gh api - CACHE_ID=$(gh api repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/caches --jq ".actions_caches[] | select(.key == \"$CACHE_KEY\") | .id") - - if [ -n "$CACHE_ID" ]; then - echo "Deleting cache with key $CACHE_KEY (ID: $CACHE_ID)" - gh api --method DELETE repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/caches/$CACHE_ID - else - echo "Cache with key $CACHE_KEY not found." - fi + run: gh cache delete "snapshot-build-${{ github.run_id }}" + env: + GH_TOKEN: ${{ github.token }}