diff --git a/.github/workflows/validations.yaml b/.github/workflows/validations.yaml index 709e1bfe972..0ebca5c8235 100644 --- a/.github/workflows/validations.yaml +++ b/.github/workflows/validations.yaml @@ -208,22 +208,16 @@ jobs: name: "Cleanup snapshot cache" if: always() runs-on: ubuntu-20.04 + permissions: + actions: write needs: - Acceptance-Linux - Acceptance-Mac - Cli-Linux steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7 + - 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 }}