Skip to content

Commit

Permalink
attempt to clear cache #6
Browse files Browse the repository at this point in the history
  • Loading branch information
bahill committed Nov 14, 2024
1 parent 86b23e0 commit b2e28a4
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions .github/workflows/clean_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,10 @@ on:
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
# `actions:write` permission is required to delete caches
# See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
actions: write
contents: read
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Cleanup
- name: Clear Poetry Artifacts
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
echo "these are the cache keys"
echo "$cacheKeysForPR"
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.BH_GH_TOKEN_TO_CLEAN_CACHE }}
rm -rf ~/.cache/pypoetry/artifacts

0 comments on commit b2e28a4

Please sign in to comment.