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 0d857f9
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/validations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 0d857f9

Please sign in to comment.