Skip to content

Commit cbb1eb5

Browse files
committed
Fix install-go cache key
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
1 parent 8ae593f commit cbb1eb5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/actions/setup-go/action.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ inputs:
88
runs:
99
using: 'composite'
1010
steps:
11+
# On self-hosted runners, the env.ImageOS variable may not be set correctly, which can cause issues with the cache key.
12+
# We need to handle this case to ensure the cache key is consistent.
13+
- name: Set ImageOS
14+
if: ${{ runner.os == 'Linux' && env.ImageOS == '' }}
15+
shell: bash
16+
# Key is ubuntu<MAJOR>, as there is not other linux os in GHA other than Ubuntu
17+
run: echo "ImageOS=ubuntu$(lsb_release -rs | cut -d. -f1)" >> $GITHUB_ENV
18+
1119
- name: Find Latest Release Branch
1220
shell: bash
1321
run: |
@@ -41,4 +49,4 @@ runs:
4149
# Match the cache key to the setup-go action https://github.com/actions/setup-go/blob/main/src/cache-restore.ts#L34
4250
key: setup-go-${{ runner.os }}-${{ env.ImageOS }}-go-${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }}
4351
restore-keys: |
44-
setup-go-${{ runner.os }}-
52+
setup-go-${{ runner.os }}-${{ env.ImageOS }}-go-${{ env.GO_VERSION }}-

0 commit comments

Comments
 (0)