diff --git a/.github/workflows/cleanup-caches.yml b/.github/workflows/cleanup-caches.yml index e73aaa51a..763b5f856 100644 --- a/.github/workflows/cleanup-caches.yml +++ b/.github/workflows/cleanup-caches.yml @@ -1,4 +1,4 @@ -name: cleanup caches by a branch +name: souji on: pull_request: types: @@ -11,30 +11,6 @@ jobs: permissions: # 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 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} steps: - name: Cleanup - env: - BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} - MERGE_BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge - run: | - gh extension install actions/gh-actions-cache - - echo "Fetching list of cache key" - cacheKeysForBranch=$(gh actions-cache list --branch=$BRANCH --limit=100 | cut -f 1 ) - cacheKeysForPR=$(gh actions-cache list --branch=$MERGE_BRANCH --limit=100 | cut -f 1 ) - - ## Setting this to not fail the workflow while deleting cache keys. - set +e - echo "Deleting caches..." - for cacheKey in $cacheKeysForBranch - do - gh actions-cache delete $cacheKey --branch=$BRANCH --confirm - done - for cacheKey in $cacheKeysForPR - do - gh actions-cache delete $cacheKey --branch=$MERGE_BRANCH --confirm - done - echo "Done" + uses: 4m-mazi/souji-action@d6224b7c49f3e54c46ef63ed08f4652568269679