Skip to content

Commit

Permalink
Only save a cache if it doesn't exist (overwrite doesn't work) (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeage committed Nov 21, 2023
1 parent 11019b0 commit b00ed29
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ jobs:
rm -rf tmp.plugin tmp.package
- name: Restore Library/
id: cache_library
uses: actions/cache/restore@v3
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10
Expand All @@ -304,6 +305,7 @@ jobs:
key: Library_${{ matrix.cache }}_${{ env.UNITY_VERSION }}

- name: Restore Library/PackageCache
id: cache_packagecache
uses: actions/cache/restore@v3
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10
Expand Down Expand Up @@ -422,14 +424,15 @@ jobs:

- name: Save Library/PackageCache cache
uses: actions/cache/save@v3
if: github.ref == 'refs/heads/main' # Ideally, we'd save caches on branches, but they're too big, and branch caches can evict those from main, which is unacceptable.
if: github.ref == 'refs/heads/main' && steps.cache_packagecache.outputs.cache-hit != 'true' # Ideally, we'd save caches on branches, but they're too big, and branch caches can evict those from main, which is unacceptable.
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10
with:
path: Library/PackageCache
key: Library_PackageCache_${{ env.UNITY_VERSION }}

- name: Clean Library before caching
if: github.ref == 'refs/heads/main' && steps.cache_library.outputs.cache-hit != 'true' # Ideally, we'd save caches on branches, but they're too big, and branch caches can evict those from main, which is unacceptable.
run: |
# Remove the large files from the Library directory that we know we'll rebuild. As our il2cpp caches are huge and barely fit in the Github quota, it's better not to save an unneeded 1GB of space (or so). If a new Unity version is taken, this may need to be updated
# Debugging
Expand All @@ -448,7 +451,7 @@ jobs:
- name: Save Library/ cache
uses: actions/cache/save@v3
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && steps.cache_library.outputs.cache-hit != 'true' # Ideally, we'd save caches on branches, but they're too big, and branch caches can evict those from main, which is unacceptable.
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10
with:
Expand Down

0 comments on commit b00ed29

Please sign in to comment.