Skip to content

Instantly share code, notes, and snippets.

@abemedia
Created March 21, 2023 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abemedia/39c60f9ec136a913f9fdb83e5f04e26d to your computer and use it in GitHub Desktop.
Save abemedia/39c60f9ec136a913f9fdb83e5f04e26d to your computer and use it in GitHub Desktop.
GitHub Actions Go Cache
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: false
- name: Set cache paths
id: go-cache-paths
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: go-build-${{ runner.os }}-${{ github.sha }}
restore-keys: go-build-${{ runner.os }}-
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: go-mod-
- name: Download dependencies
run: go mod download
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment