From c582de2cf26d7fe2c78e19d49a91d927533020c5 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Mon, 29 May 2023 00:54:10 +0200 Subject: [PATCH] ci(dataverse): clear cache before trying to save to it again --- .github/workflows/maven_unit_test.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven_unit_test.yml b/.github/workflows/maven_unit_test.yml index 690c414ff94..9464b753579 100644 --- a/.github/workflows/maven_unit_test.yml +++ b/.github/workflows/maven_unit_test.yml @@ -72,14 +72,25 @@ jobs: -DrepoToken=${COVERALLS_SECRET} -DpullRequest=${{ github.event.number }} jacoco:report coveralls:report - # We don't want to cache the WAR file, so delete it - - run: rm -rf ~/.m2/repository/edu/harvard/iq/dataverse + # Prepare to replace the cache. Also: we don't want to cache the WAR file, so delete it + - id: clear-cache + if: ${{ steps.restore-m2-cache.outputs.cache-hit }} + continue-on-error: true # This is not crucial, just carry on + env: + GH_TOKEN: ${{ github.token }} + run: | + rm -rf ~/.m2/repository/edu/harvard/iq/dataverse + + gh extension install actions/gh-actions-cache + gh actions-cache delete ${{ steps.restore-m2-cache.outputs.cache-primary-key }} --confirm + # To cache built Maven submodules, summon the save to cache action - name: Save Maven packages in Cache uses: actions/cache/save@v3 + if: always() # Try to save cache, will not fail if key still exists because clean failed with: path: ~/.m2 - key: ${{ steps.restore-m2-cache.outputs.cache-primary-key }}-${{ github.run_id }} + key: ${{ steps.restore-m2-cache.outputs.cache-primary-key }} push-app-img: name: Publish App Image permissions: