From 856766b160115bb09d76a4db0c989a5258e42b22 Mon Sep 17 00:00:00 2001
From: Daniel Shuy <daniel_shuy@hotmail.com>
Date: Fri, 14 Aug 2020 17:43:42 +0800
Subject: [PATCH] Remove build.sbt hash from SBT cache keys

SBT dependencies can be defined outside build.sbt, therefore hash of build.sbt is not reliable to determine if dependencies have changed
---
 examples.md | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/examples.md b/examples.md
index bfd0476..c63c857 100644
--- a/examples.md
+++ b/examples.md
@@ -443,12 +443,16 @@ SBT 1.2
   uses: actions/cache@v2
   with:
     path: ~/.ivy2/cache
-    key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-ivy-cache-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-ivy-cache-
 - name: Cache SBT
   uses: actions/cache@v2
   with:
     path: ~/.sbt
-    key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-
 ```
 
 SBT 1.3.0-1.3.10
@@ -457,17 +461,23 @@ SBT 1.3.0-1.3.10
   uses: actions/cache@v2
   with:
     path: ~/.ivy2/cache
-    key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-ivy-cache-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-ivy-cache-
 - name: Cache SBT coursier cache
   uses: actions/cache@v2
   with:
     path: ~/.coursier/cache
-    key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-coursier-cache-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-coursier-cache-
 - name: Cache SBT
   uses: actions/cache@v2
   with:
     path: ~/.sbt
-    key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-
 ```
 
 SBT 1.3.11+
@@ -476,30 +486,40 @@ SBT 1.3.11+
   uses: actions/cache@v2
   with:
     path: ~/.ivy2/cache
-    key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-ivy-cache-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-ivy-cache-
 - name: Cache SBT coursier cache (Linux)
   uses: actions/cache@v2
   if: startsWith(runner.os, 'Linux')
   with:
     path: ~/.cache/coursier/v1
-    key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-coursier-cache-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-coursier-cache-
 - name: Cache SBT coursier cache (macOS)
   uses: actions/cache@v2
   if: startsWith(runner.os, 'macOS')
   with:
     path: ~/Library/Caches/Coursier/v1
-    key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-coursier-cache-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-coursier-cache-
 - name: Cache SBT coursier cache (Windows)
   uses: actions/cache@v2
   if: startsWith(runner.os, 'Windows')
   with:
     path: ~\AppData\Local\Coursier\Cache\v1
-    key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-coursier-cache-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-coursier-cache-
 - name: Cache SBT
   uses: actions/cache@v2
   with:
     path: ~/.sbt
-    key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
+    key: ${{ runner.os }}-sbt-${{ github.run_id }}
+    restore-keys: |
+      ${{ runner.os }}-sbt-
 ```
 
 ## Swift, Objective-C - Carthage