23
23
- ' **.md'
24
24
25
25
env :
26
- DOCKER_BUILDKIT : 1
26
+ platforms : " linux/amd64,linux/arm64,linux/ppc64le,linux/s390x "
27
27
28
28
concurrency :
29
29
group : ${{ github.ref_name }}-ci
@@ -55,17 +55,21 @@ jobs:
55
55
steps :
56
56
- name : Checkout Repository
57
57
uses : actions/checkout@v2
58
+ - name : Cache Go build
59
+ uses : actions/cache@v2
60
+ with :
61
+ path : |
62
+ ~/.cache/go-build
63
+ ~/go/pkg/mod
64
+ key : ${{ runner.os }}-go-local-build-${{ hashFiles('**/go.sum') }}
65
+ restore-keys : |
66
+ ${{ runner.os }}-go-local-build-
58
67
- name : Setup Golang Environment
59
68
uses : actions/setup-go@v2
60
69
with :
61
70
go-version : ${{ needs.vars.outputs.go_version }}
62
71
- name : Build Binary
63
72
run : make build
64
- - name : Cache Artifacts
65
- uses : actions/cache@v2
66
- with :
67
- path : ${{ github.workspace }}/bin/manager
68
- key : nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
69
73
70
74
unit-tests :
71
75
name : Unit Tests
@@ -78,27 +82,59 @@ jobs:
78
82
uses : actions/setup-go@v2
79
83
with :
80
84
go-version : ${{ needs.vars.outputs.go_version }}
85
+ - name : Cache Go tests
86
+ uses : actions/cache@v2
87
+ with :
88
+ path : |
89
+ ~/.cache/go-build
90
+ ~/go/pkg/mod
91
+ key : ${{ runner.os }}-go-tests-${{ hashFiles('**/go.sum') }}
92
+ restore-keys : |
93
+ ${{ runner.os }}-go-tests-
81
94
- name : Run Tests
82
95
run : make test
83
96
84
97
build :
85
98
name : Build Image
86
99
runs-on : ubuntu-20.04
87
- needs : [binary, unit-tests]
100
+ needs : [binary, vars, unit-tests]
88
101
steps :
89
102
- name : Checkout Repository
90
103
uses : actions/checkout@v2
91
- - name : Fetch Cached Artifacts
104
+ with :
105
+ fetch-depth : 0
106
+ - name : Cache Go build
92
107
uses : actions/cache@v2
93
108
with :
94
- path : ${{ github.workspace }}/bin/manager
95
- key : nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
109
+ path : |
110
+ ~/.cache/go-build
111
+ ~/go/pkg/mod
112
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
113
+ restore-keys : |
114
+ ${{ runner.os }}-go-build-
115
+ - name : Setup Golang Environment
116
+ uses : actions/setup-go@v2
117
+ with :
118
+ go-version : ${{ needs.vars.outputs.go_version }}
119
+ - name : Build binaries
120
+ uses : goreleaser/goreleaser-action@v2
121
+ with :
122
+ version : latest
123
+ args : ${{ !startsWith(github.ref, 'refs/tags/') && 'build --snapshot' || 'release' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --rm-dist
124
+ env :
125
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
126
+ GOPATH : ${{ needs.check.outputs.go_path }}
96
127
- name : DockerHub Login
97
128
uses : docker/login-action@v1
98
129
with :
99
130
username : ${{ secrets.DOCKER_USERNAME }}
100
131
password : ${{ secrets.DOCKER_PASSWORD }}
101
132
if : github.event_name != 'pull_request'
133
+ - name : Setup QEMU
134
+ uses : docker/setup-qemu-action@v1
135
+ with :
136
+ platforms : arm64,ppc64le,s390x
137
+ if : github.event_name != 'pull_request'
102
138
- name : Docker Buildx
103
139
uses : docker/setup-buildx-action@v1
104
140
- name : Docker meta
@@ -122,6 +158,7 @@ jobs:
122
158
cache-to : type=gha,mode=max
123
159
tags : ${{ steps.meta.outputs.tags }}
124
160
labels : ${{ steps.meta.outputs.labels }}
161
+ platforms : ${{ github.event_name != 'pull_request' && env.platforms || '' }}
125
162
load : ${{ github.event_name == 'pull_request' }}
126
163
push : ${{ github.event_name != 'pull_request' }}
127
164
pull : true
0 commit comments