Skip to content

chore(deps): update dependency husky to ^9.1.6 #38

chore(deps): update dependency husky to ^9.1.6

chore(deps): update dependency husky to ^9.1.6 #38

# From https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
name: "Cleanup caches by a branch"
on: # yamllint disable-line rule:truthy
pull_request:
types:
- "closed"
workflow_dispatch: # yamllint disable-line rule:empty-values
workflow_call:
inputs:
target-repo:
description: "The repo to run this action on. This is to prevent actions from running on forks unless intended."
required: true
type: "string"
jobs:
cleanup:
if: "github.repository == inputs.target-repo"
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: "Harden Runner"
uses: "step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde" # v2.9.1
with:
egress-policy: "audit"
- name: "Git checkout"
uses: "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" # v4.1.7
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
- name: "Cleanup"
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 )
## 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.GITHUB_TOKEN }}"
REPO: "${{ github.repository }}"
BRANCH: "refs/pull/${{ github.event.pull_request.number }}/merge"