From 13f94fdadf73a5bb2510a562c56e3aa53dc12755 Mon Sep 17 00:00:00 2001 From: Wojtek Piotrowiak Date: Wed, 22 Nov 2023 17:35:11 +0100 Subject: [PATCH] AAE-18301 new action to clean GH cache after pr merge (#381) [skip ci] --- .../gh-cache-cleanup-on-merge/action.yml | 29 +++++++++++++++++++ .github/dependabot.yml | 4 +++ docs/README.md | 20 +++++++++++++ version.txt | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/actions/gh-cache-cleanup-on-merge/action.yml diff --git a/.github/actions/gh-cache-cleanup-on-merge/action.yml b/.github/actions/gh-cache-cleanup-on-merge/action.yml new file mode 100644 index 000000000..74ecda9a3 --- /dev/null +++ b/.github/actions/gh-cache-cleanup-on-merge/action.yml @@ -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 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4f10a0926..4135c542b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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: diff --git a/docs/README.md b/docs/README.md index ca639f06b..72bf9bde0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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 diff --git a/version.txt b/version.txt index 32f8572ea..5f22788f5 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v3.8.1 +v3.9.0