diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2021-05-11 10:46:41 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-11 10:46:41 +0900 |
commit | 4f93cf9d758e54de0fad0787b0de20ae81b1e14b (patch) | |
tree | f4094e11bb43a4291b5caa3fcaa2ffc042c40400 | |
parent | 640d431b35860913ed376cf781da1b8b1a73d0a4 (diff) |
ci: create cache always in main, skip saving cache in PRs (#10560)
-rw-r--r-- | .github/workflows/ci.yml | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bf978601..cb4390796 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,13 +190,36 @@ jobs: key: a-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }} - - name: Cache build output - uses: actions/cache@v2 + # In main branch, always creates fresh cache + - name: Cache build output (main) + # TODO(kt3k): Change the version to the released version + # when https://github.com/actions/cache/pull/489 (or 571) is merged. + uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + if: github.ref == 'refs/heads/main' with: path: | ./target - key: - a-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ hashFiles('Cargo.lock') }} + key: | + a-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }} + + # Restores cache from the latest main branch's Cache + - name: Cache build output (PR) + # TODO(kt3k): Change the version to the released version + # when https://github.com/actions/cache/pull/489 (or 571) is merged. + uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + if: github.ref != 'refs/heads/main' + with: + path: | + ./target + key: | + dummy # Cache never be created for this key. + restore-keys: | + a-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ hashFiles('Cargo.lock') }}- + + # Skips saving cache in PR branches + - name: Skip save cache (PR) + run: echo "CACHE_SKIP_SAVE=true" >> $GITHUB_ENV + if: github.ref != 'refs/heads/main' - name: Apply and update mtime cache uses: ./.github/mtime_cache |