Skip to content

Commit

Permalink
ci: Only save caches on main and release branches
Browse files Browse the repository at this point in the history
This restores caches on all branches and pull requests, but only stores
them on the main branch and release branches. This prevents those caches
from being evicted early when we hit the 10 GB limit quickly.
  • Loading branch information
wolfgangwalther committed May 12, 2024
1 parent aef29d4 commit 4dc6ce3
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ jobs:
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Stack working files cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
- name: Restore stack working files cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: restore-cache
with:
path: ${{ matrix.cache }}
key: stack-${{ runner.os }}-${{ hashFiles('stack.yaml.lock') }}
Expand All @@ -137,6 +138,12 @@ jobs:
result/postgrest
result/postgrest.exe
if-no-files-found: error
- name: Save stack working files cache
if: startsWith(github.ref, 'refs/heads/')
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ matrix.cache }}
key: ${{ steps.restore-cache.outputs.cache-primary-key }}


freebsd:
Expand Down Expand Up @@ -170,8 +177,9 @@ jobs:
- name: Fix caching
run: |
mkdir ~/.cabal
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
- name: Restore cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: restore-cache
with:
path: |
~/.cabal/packages
Expand All @@ -186,3 +194,12 @@ jobs:
cabal build --only-dependencies --enable-tests --enable-benchmarks
- name: Build
run: cabal build --enable-tests --enable-benchmarks all
- name: Save cache
if: startsWith(github.ref, 'refs/heads/')
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

0 comments on commit 4dc6ce3

Please sign in to comment.