Skip to content

Commit

Permalink
ci: Purge old cached assets in workflows (#437)
Browse files Browse the repository at this point in the history
* ci: Add automated branch cache cleanup

* Add manual cache purge

* Split actions and cache cleaning
  • Loading branch information
ankurdotb committed Nov 3, 2022
1 parent bbe8b3f commit a445fc0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Cleanup"
name: "Cleanup - Actions"
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -30,7 +30,7 @@ on:

jobs:

del-runs:
delete-runs:
name: "Delete old workflow runs"
runs-on: ubuntu-latest

Expand All @@ -43,4 +43,3 @@ jobs:
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}

21 changes: 21 additions & 0 deletions .github/workflows/cleanup-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Cleanup - Cache"
on:
workflow_dispatch:
inputs:
dry-run:
description: "Dry run only?"
required: true
type: boolean
default: false

jobs:

delete-caches:
name: "Delete Actions caches"
runs-on: ubuntu-latest

steps:
- name: "Wipe Github Actions cache"
uses: easimon/wipe-cache@v1
with:
dry-run: ${{ github.event.inputs.dry-run }}
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,17 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=min

cache-purge:
name: "Purge branch Actions cache"
needs: [release-binary, release-docker]
runs-on: ubuntu-latest

steps:

- name: "Delete Branch Cache Action"
uses: snnaplab/delete-branch-cache-action@v1.0.0
with:
# Specify explicitly because the ref at the time of merging will be a branch name such as 'main', 'develop'
ref: refs/pull/${{ github.event.number }}/merge
github-token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit a445fc0

Please sign in to comment.