Skip to content

Commit 5da1ff8

Browse files
committed
setup_go_with_cache: change restore-keys for go build cache to include go-version
restoring cache from different go version seems not efficient. Signed-off-by: Norio Nomura <[email protected]>
1 parent 8cd0d22 commit 5da1ff8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.github/actions/setup_go_with_cache/action.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ runs:
5151
working-directory: ${{ inputs.working-directory }}
5252
- id: base-key
5353
run: |
54-
echo "gomodcache-key=go-modcache-${{ inputs.working-directory }}" >> $GITHUB_OUTPUT
55-
echo "gocache-key=go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.additional-gocache-key }}" >> $GITHUB_OUTPUT
54+
echo "gomodcache-key=go-modcache-${WORKING_DIRECTORY}" >> $GITHUB_OUTPUT
55+
echo "gocache-key=go-cache-${WORKING_DIRECTORY}-${RUNS_ON}-${ADDITIONAL_GOCACHE_KEY}-${GO_VERSION}" >> $GITHUB_OUTPUT
5656
shell: bash
57+
env:
58+
ADDITIONAL_GOCACHE_KEY: ${{ inputs.additional-gocache-key }}
59+
GO_VERSION: ${{ steps.setup-go.outputs.go-version }}
60+
RUNS_ON: ${{ inputs.runs-on }}
61+
WORKING_DIRECTORY: ${{ inputs.working-directory }}
5762
- name: Cache go modules
5863
uses: actions/cache@v4
5964
with:
@@ -67,9 +72,8 @@ runs:
6772
uses: actions/cache@v4
6873
with:
6974
path: ${{ steps.go-env.outputs.GOCACHE }}
70-
key: ${{ steps.base-key.outputs.gocache-key }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }}
75+
key: ${{ steps.base-key.outputs.gocache-key }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }}
7176
restore-keys: |
72-
${{ steps.base-key.outputs.gocache-key }}-${{ steps.setup-go.outputs.go-version }}-
7377
${{ steps.base-key.outputs.gocache-key }}-
7478
- name: Download dependencies
7579
if: inputs.ignore-go-mod-and-go-sum != 'true'

0 commit comments

Comments
 (0)