Skip to content

Commit

Permalink
Merge pull request #22663 from mrclary/purge-cache
Browse files Browse the repository at this point in the history
PR: Purge workflow cache weekly
  • Loading branch information
ccordoba12 authored Oct 12, 2024
2 parents a3920dd + 8a0a490 commit 065afeb
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 1 deletion.
63 changes: 63 additions & 0 deletions .github/workflows/purge-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Purge caches
on:
schedule:
# 4:10 UTC Sunday
- cron: "10 4 * * 0"

workflow_dispatch:

jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Purge Cache
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
echo "Fetching list of cache key"
allCaches=$(gh actions-cache list -L 100 -R $REPO | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $allCaches
do
gh actions-cache delete $cacheKey -R $REPO --confirm
done
echo "Done"
run-test-files:
name: Run test-files
needs:
- cleanup
uses: ./.github/workflows/test-files.yml

run-test-linux:
name: Run test-linux
needs:
- cleanup
uses: ./.github/workflows/test-linux.yml

run-test-mac:
name: Run test-mac
needs:
- cleanup
uses: ./.github/workflows/test-mac.yml

run-test-remoteclient:
name: Run test-remoteclient
needs:
- cleanup
uses: ./.github/workflows/test-remoteclient.yml

run-test-win:
name: Run test-win
needs:
- cleanup
uses: ./.github/workflows/test-win.yml
4 changes: 4 additions & 0 deletions .github/workflows/test-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

pull_request:
branches:
Expand All @@ -34,6 +35,9 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

workflow_call:

workflow_dispatch:

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

pull_request:
branches:
Expand All @@ -34,6 +35,9 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

workflow_call:

workflow_dispatch:
inputs:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

pull_request:
branches:
Expand All @@ -34,6 +35,9 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

workflow_call:

workflow_dispatch:
inputs:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test-remoteclient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

pull_request:
branches:
Expand All @@ -30,11 +31,14 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

workflow_call:

workflow_dispatch:
inputs:
ssh:
# github_cli: gh workflow run test-linux.yml --ref <branch> -f ssh=true
# github_cli: gh workflow run test-remoteclient.yml --ref <branch> -f ssh=true
description: 'Enable ssh debugging'
required: false
default: false
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

pull_request:
branches:
Expand All @@ -34,6 +35,9 @@ on:
- '!installers-conda/**'
- '!.github/workflows/installers-conda.yml'
- '!.github/workflows/build-subrepos.yml'
- '!.github/workflows/purge-cache.yml'

workflow_call:

workflow_dispatch:
inputs:
Expand Down

0 comments on commit 065afeb

Please sign in to comment.