Skip to content

Commit c582de2

Browse files
committed
ci(dataverse): clear cache before trying to save to it again
1 parent e6bc0e4 commit c582de2

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/maven_unit_test.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,25 @@ jobs:
7272
-DrepoToken=${COVERALLS_SECRET} -DpullRequest=${{ github.event.number }}
7373
jacoco:report coveralls:report
7474
75-
# We don't want to cache the WAR file, so delete it
76-
- run: rm -rf ~/.m2/repository/edu/harvard/iq/dataverse
75+
# Prepare to replace the cache. Also: we don't want to cache the WAR file, so delete it
76+
- id: clear-cache
77+
if: ${{ steps.restore-m2-cache.outputs.cache-hit }}
78+
continue-on-error: true # This is not crucial, just carry on
79+
env:
80+
GH_TOKEN: ${{ github.token }}
81+
run: |
82+
rm -rf ~/.m2/repository/edu/harvard/iq/dataverse
83+
84+
gh extension install actions/gh-actions-cache
85+
gh actions-cache delete ${{ steps.restore-m2-cache.outputs.cache-primary-key }} --confirm
86+
7787
# To cache built Maven submodules, summon the save to cache action
7888
- name: Save Maven packages in Cache
7989
uses: actions/cache/save@v3
90+
if: always() # Try to save cache, will not fail if key still exists because clean failed
8091
with:
8192
path: ~/.m2
82-
key: ${{ steps.restore-m2-cache.outputs.cache-primary-key }}-${{ github.run_id }}
93+
key: ${{ steps.restore-m2-cache.outputs.cache-primary-key }}
8394
push-app-img:
8495
name: Publish App Image
8596
permissions:

0 commit comments

Comments
 (0)