66 - ' *'
77 tags :
88 - ' v*'
9+ pull_request :
10+ branches :
11+ - master
912
1013jobs :
1114 build :
1215 runs-on : ubuntu-latest
1316 steps :
1417 # dependencies
1518 - name : goreleaser
16- uses : goreleaser/goreleaser-action@v2
19+ uses : goreleaser/goreleaser-action@v3
1720 with :
1821 install-only : true
1922 version : 1.7.0
@@ -28,20 +31,22 @@ jobs:
2831 run : task --version
2932
3033 - name : qemu
31- uses : docker/setup-qemu-action@v1
34+ if : github.event.pull_request.head.repo.fork == false
35+ uses : docker/setup-qemu-action@v2
3236
3337 - name : buildx
34- uses : docker/setup-buildx-action@v1
38+ if : github.event.pull_request.head.repo.fork == false
39+ uses : docker/setup-buildx-action@v2
3540
3641 # checkout
3742 - name : checkout
38- uses : actions/checkout@v2
43+ uses : actions/checkout@v3
3944 with :
4045 fetch-depth : 0
4146
4247 # setup go
4348 - name : go
44- uses : actions/setup-go@v1
49+ uses : actions/setup-go@v3
4550 with :
4651 go-version : 1.19
4752
@@ -51,26 +56,18 @@ jobs:
5156 go env
5257
5358 # cache
54- - name : cache-paths
55- id : go-cache-paths
56- run : |
57- echo "::set-output name=go-build::$(go env GOCACHE)"
58- echo "::set-output name=go-mod::$(go env GOMODCACHE)"
59-
60- - name : cache-build
61- uses : actions/cache@v2
62- with :
63- path : ${{ steps.go-cache-paths.outputs.go-build }}
64- key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
65-
66- - name : cache-mod
67- uses : actions/cache@v2
59+ - name : cache-go
60+ uses : actions/cache@v3
6861 with :
69- path : ${{ steps.go-cache-paths.outputs.go-mod }}
70- key : ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
62+ path : |
63+ ~/.cache/go-build
64+ ~/go/pkg/mod
65+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
66+ restore-keys : |
67+ ${{ runner.os }}-go-cache-mod
7168
7269 - name : cache-task
73- uses : actions/cache@v2
70+ uses : actions/cache@v3
7471 with :
7572 path : .task/**/*
7673 key : ${{ runner.os }}-go-task
@@ -106,19 +103,20 @@ jobs:
106103
107104 # artifacts
108105 - name : artifact_linux
109- uses : actions/upload-artifact@v2-preview
106+ uses : actions/upload-artifact@v3
110107 with :
111108 name : build_linux
112109 path : dist/*linux*
113110
114111 - name : artifact_darwin
115- uses : actions/upload-artifact@v2-preview
112+ uses : actions/upload-artifact@v3
116113 with :
117114 name : build_darwin
118115 path : dist/*darwin*
119116
120117 # docker login
121118 - name : docker login
119+ if : github.event.pull_request.head.repo.fork == false
122120 env :
123121 DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
124122 DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
@@ -127,15 +125,15 @@ jobs:
127125
128126 # docker build (latest & tag)
129127 - name : release tag
130- if : startsWith(github.ref, 'refs/tags/') == true
128+ if : startsWith(github.ref, 'refs/tags/') == true && github.event.pull_request.head.repo.fork == false
131129 uses : little-core-labs/get-git-tag@v3.0.2
132130 id : releasetag
133131 with :
134132 tagRegex : " v?(.+)"
135133
136134 - name : docker - build release
137- if : startsWith(github.ref, 'refs/tags/') == true
138- uses : docker/build-push-action@v2
135+ if : startsWith(github.ref, 'refs/tags/') == true && github.event.pull_request.head.repo.fork == false
136+ uses : docker/build-push-action@v3
139137 with :
140138 context : .
141139 file : ./docker/Dockerfile
@@ -150,13 +148,13 @@ jobs:
150148
151149 # docker build (branch)
152150 - name : branch name
153- if : startsWith(github.ref, 'refs/tags/') == false
151+ if : startsWith(github.ref, 'refs/tags/') == false && github.event.pull_request.head.repo.fork == false
154152 id : branch-name
155- uses : tj-actions/branch-names@v2 .2
153+ uses : tj-actions/branch-names@v6 .2
156154
157155 - name : docker tag
158- if : startsWith(github.ref, 'refs/tags/') == false
159- uses : frabert/replace-string-action@master
156+ if : startsWith(github.ref, 'refs/tags/') == false && github.event.pull_request.head.repo.fork == false
157+ uses : frabert/replace-string-action@v2.3
160158 id : dockertag
161159 with :
162160 pattern : ' [:\.\/]+'
@@ -165,8 +163,8 @@ jobs:
165163 flags : ' g'
166164
167165 - name : docker - build branch
168- if : startsWith(github.ref, 'refs/tags/') == false
169- uses : docker/build-push-action@v2
166+ if : startsWith(github.ref, 'refs/tags/') == false && github.event.pull_request.head.repo.fork == false
167+ uses : docker/build-push-action@v3
170168 with :
171169 context : .
172170 file : ./docker/Dockerfile
@@ -180,5 +178,6 @@ jobs:
180178
181179 # cleanup
182180 - name : cleanup
181+ if : github.event.pull_request.head.repo.fork == false
183182 run : |
184183 rm -f ${HOME}/.docker/config.json
0 commit comments