Skip to content

Commit

Permalink
ci: Only save caches on main
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. This prevents those caches from being evicted early when we hit the 10 GB limit
quickly.
  • Loading branch information
wolfgangwalther committed Mar 4, 2024
1 parent a329787 commit 112574c
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Stack working files cache
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1.0.1
- name: Restore stack working files cache
uses: actions/cache/restore@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
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: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v4
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@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1.0.1
- name: Restore cache
uses: actions/cache/restore@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
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: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v4
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

0 comments on commit 112574c

Please sign in to comment.