Skip to content

Commit f10059e

Browse files
committed
Cache go modules
1 parent f9943ba commit f10059e

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
name: build
22

33
on:
4-
pull_request:
5-
branches: master
64
push:
7-
branches: master
8-
tags: v*
5+
branches: 'master'
6+
tags: 'v*'
7+
paths:
8+
- '.github/workflows/build.yml'
9+
- 'cmd/**'
10+
- 'internal/**'
11+
- '.goreleaser.yml'
12+
- 'Dockerfile'
13+
- 'go.mod'
14+
- 'go.sum'
915

1016
jobs:
1117
go:
1218
runs-on: ubuntu-latest
1319
steps:
20+
-
21+
# https://github.com/actions/checkout
22+
name: Checkout
23+
uses: actions/checkout@v1
1424
-
1525
name: Prepare
1626
id: prepare
@@ -25,15 +35,14 @@ jobs:
2535
with:
2636
go-version: 1.12.10
2737
-
28-
name: Set GOPATH
29-
# temporary fix (see https://github.com/actions/setup-go/issues/14)
30-
run: |
31-
echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)"
32-
echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin"
33-
-
34-
# https://github.com/actions/checkout
35-
name: Checkout
36-
uses: actions/checkout@v1
38+
# https://github.com/actions/cache
39+
name: Cache Go modules
40+
uses: actions/cache@v1
41+
with:
42+
path: ~/go/pkg/mod
43+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
44+
restore-keys: |
45+
${{ runner.os }}-go-
3746
-
3847
# https://github.com/goreleaser/goreleaser-action
3948
name: GoReleaser
@@ -59,6 +68,10 @@ jobs:
5968
runs-on: ubuntu-latest
6069
needs: go
6170
steps:
71+
-
72+
# https://github.com/actions/checkout
73+
name: Checkout
74+
uses: actions/checkout@v1
6275
-
6376
name: Prepare
6477
id: prepare
@@ -78,10 +91,6 @@ jobs:
7891
uses: crazy-max/ghaction-docker-buildx@v1
7992
with:
8093
version: latest
81-
-
82-
# https://github.com/actions/checkout
83-
name: Checkout
84-
uses: actions/checkout@v1
8594
-
8695
name: Docker Buildx (no push)
8796
run: |

0 commit comments

Comments
 (0)