Created
March 21, 2023 03:08
-
-
Save abemedia/39c60f9ec136a913f9fdb83e5f04e26d to your computer and use it in GitHub Desktop.
GitHub Actions Go Cache
This file contains hidden or 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
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