Skip to content

Commit

Permalink
AAE-18301 new action to clean GH cache after pr merge (#381)
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
wojciech-piotrowiak authored Nov 22, 2023
1 parent c65d194 commit 13f94fd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/actions/gh-cache-cleanup-on-merge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "GH cache cleanup"
description: "Performs the cleanup of cache entries related with already closed PR"
inputs:
token:
description: The GH token
required: true
runs:
using: composite
steps:
- name: Cache cleanup
shell: bash
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | 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: ${{ inputs.token }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ updates:
directory: "/.github/actions/get-commit-message"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/.github/actions/gh-cache-cleanup-on-merge"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/.github/actions/git-check-existing-tag"
schedule:
Expand Down
20 changes: 20 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,26 @@ Runs Veracode Source Clear Scan
srcclr-install-options: '-DskipTestModules' # optional, additional maven options
```

### github cache cleanup

Performs the cleanup of cache entries related with already closed PR

```yaml
name: Cleanup caches for work branch
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: Alfresco/alfresco-build-tools/.github/actions/gh-cache-cleanup-on-merge@ref
with:
token: ${{ secrets.GH_TOKEN }}
```

## Reusable workflows provided by us

### helm-publish-new-package-version.yml
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.8.1
v3.9.0

0 comments on commit 13f94fd

Please sign in to comment.