Skip to content

Commit

Permalink
simplify deleting cache
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Sep 6, 2024
1 parent 5a05bca commit 0070827
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/validations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 0070827

Please sign in to comment.