Skip to content

Commit

Permalink
build: add gha cache for go and docker (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood authored Jul 25, 2024
1 parent 6a6a40e commit 95d116a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "^1.21"
go-version: '1.21'
cache-dependency-path: ./go.mod
- name: Set up environment
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV
- name: Run GoReleaser
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Cache
uses: actions/cache@v4
id: cache
with:
path: |
go-mod
go-build
key: cache-${{ hashFiles('**/go.mod') }}
-
name: inject cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"go-mod": "/go/pkg/mod",
"go-build": "/root/.cache/go-build"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
-
name: Build and push
uses: docker/build-push-action@v5
Expand All @@ -107,6 +126,8 @@ jobs:
"VERSION=${{ env.VERSION }}"
"BUILD=${{ env.BUILD }}"
"GO_VER=${{ matrix.goversion }}"
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
7 changes: 4 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "^1.21"
go-version: '1.21'
cache-dependency-path: ./go.mod
- name: Run Tests
run: go test -v ./...

0 comments on commit 95d116a

Please sign in to comment.