Browse Source

chore(ci): cache go modules with unified key to reduce cache size

Hintay 2 months ago
parent
commit
dc0d31ff54
1 changed files with 11 additions and 1 deletions
  1. 11 1
      .github/workflows/build.yml

+ 11 - 1
.github/workflows/build.yml

@@ -157,13 +157,23 @@ jobs:
           echo "DIST=nginx-ui-$_NAME" >> $GITHUB_ENV
           echo "ARTIFACT=$_ARTIFACT" >> $GITHUB_ENV
 
-      - name: Setup go caches
+      - name: Setup Go modules cache
         uses: actions/cache@v4
         with:
           path: |
             ~/go/pkg/mod
+          key: go-${{ runner.os }}-${{ runner.arch }}-mod-${{ hashFiles('go.mod') }}
+          restore-keys: |
+            go-${{ runner.os }}-${{ runner.arch }}-mod-
+
+      - name: Setup Go build cache
+        uses: actions/cache@v4
+        with:
+          path: |
             ~/.cache/go-build
           key: go-${{ runner.os }}-${{ runner.arch }}-${{ env.CACHE_NAME }}-${{ hashFiles('go.mod') }}
+          restore-keys: |
+              go-${{ runner.os }}-${{ runner.arch }}-${{ env.CACHE_NAME }}-
 
       - name: Download app artifacts
         uses: actions/download-artifact@v4