From 98b1cf38b26e264c0084e454a28eef482d174e5a Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 6 Feb 2024 21:56:54 +0100 Subject: [PATCH] ci: Only save caches on main 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. --- .github/workflows/build.yaml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ecf62c902b..47216c265f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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') }} @@ -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: @@ -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 @@ -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 }}