Skip to content

Commit

Permalink
add cache cleanup steps
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
  • Loading branch information
wagoodman committed Sep 6, 2024
1 parent e1f985b commit 5a05bca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/actions/bootstrap/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ runs:
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ${{ github.workspace }}/.tmp/oras-cache
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-oras-cache
key: ${{ inputs.cache-key-prefix }}-oras-cache

- name: Download test fixture cache
if: inputs.download-test-fixture-cache == 'true'
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test-fixture-cache-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: "Test fixture cache: publish"

on:
workflow_dispatch:
# TODO: remove me, just here for testing
push:
schedule:
# run nightly at 4AM UTC
- cron: "0 4 * * *"
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/validations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,28 @@ jobs:

- name: Run CLI Tests (Linux)
run: make cli


Cleanup-Cache:
name: "Cleanup snapshot cache"
if: always()
runs-on: ubuntu-20.04
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

0 comments on commit 5a05bca

Please sign in to comment.