forked from k3s-io/k3s
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better GitHub CI caching strategy for golang (k3s-io#9495)
Signed-off-by: Derek Nola <derek.nola@suse.com>
- Loading branch information
Showing
4 changed files
with
30 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: 'Setup golang with master only caching' | ||
description: 'A composite action that installs golang, but with a caching strategy that only updates the cache on master branch.' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' # Just use whatever version is in the go.mod file | ||
cache: ${{ github.ref == 'refs/heads/master' }} | ||
|
||
- name: Prepare for go cache | ||
if: ${{ github.ref != 'refs/heads/master' }} | ||
run: | | ||
echo "GO_CACHE=$(go env GOCACHE)" | tee -a "$GITHUB_ENV" | ||
echo "GO_MODCACHE=$(go env GOMODCACHE)" | tee -a "$GITHUB_ENV" | ||
echo "GO_VERSION=$(go env GOVERSION | tr -d 'go')" | tee -a "$GITHUB_ENV" | ||
- name: Setup read-only cache | ||
if: ${{ github.ref != 'refs/heads/master' }} | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
${{ env.GO_MODCACHE }} | ||
${{ env.GO_CACHE }} | ||
key: setup-go-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }} | ||
restore-keys: | | ||
setup-go-${{ runner.os }}- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters