Skip to content

Commit 62bb0e0

Browse files
KapJItwpayne
authored andcommitted
chore: Optimize Go caches in Github Actions
1 parent 90c6ba1 commit 62bb0e0

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

.github/workflows/main.yml

+17-6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ jobs:
6565
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
6666
with:
6767
fetch-depth: 1
68+
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
69+
with:
70+
path: |
71+
~/.cache/go-build
72+
~/go/pkg/mod
73+
key: setup-go-${{ runner.os }}-x64-ubuntu22-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
74+
restore-keys: |
75+
setup-go-${{ runner.os }}-x64-ubuntu22-go-${{ env.GO_VERSION }}-
6876
- uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd
6977
with:
7078
languages: go
@@ -305,17 +313,15 @@ jobs:
305313
runs-on: windows-2022
306314
permissions:
307315
contents: read
316+
env:
317+
GOPATH: 'D:\golang\go'
318+
GOCACHE: 'D:\golang\cache'
319+
GOMODCACHE: 'D:\golang\modcache'
308320
steps:
309321
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
310322
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
311323
with:
312324
go-version: ${{ env.GO_VERSION }}
313-
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
314-
with:
315-
path: ~/go/pkg/mod
316-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
317-
restore-keys: |
318-
${{ runner.os }}-go-
319325
- name: build
320326
run: |
321327
go build ./...
@@ -387,6 +393,11 @@ jobs:
387393
runs-on: ${{ matrix.runs-on }}
388394
permissions:
389395
contents: read
396+
env:
397+
GOPATH: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\golang\go' || '' }}
398+
GOCACHE: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\golang\cache' || '' }}
399+
GOMODCACHE: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\golang\modcache' || '' }}
400+
USERPROFILE: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\homedir' || '' }}
390401
steps:
391402
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
392403
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed

0 commit comments

Comments
 (0)