13
13
- feature/*
14
14
15
15
jobs :
16
- check-changes :
17
- name : Check whether tests need to be run based on diff
18
- runs-on : [ ubuntu-latest]
16
+ check-env :
17
+ name : Compute outputs for use by other jobs
18
+ runs-on : ubuntu-latest
19
19
steps :
20
20
- uses : actions/checkout@v4
21
21
with :
22
22
fetch-depth : 0
23
23
show-progress : false
24
- - uses : antrea-io/has-changes@v2
24
+ - name : Check whether tests need to be run based on diff
25
+ uses : antrea-io/has-changes@v2
25
26
id : check_diff
26
27
with :
27
28
paths-ignore : docs/* ci/jenkins/* *.md hack/.notableofcontents
29
+ - name : Checking if image needs to be pushed
30
+ id : check_push
31
+ run : |
32
+ if [ "${{ github.repository }}" == "antrea-io/antrea" ] && [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
33
+ echo "push_needed=true" >> $GITHUB_OUTPUT
34
+ echo "docker_driver=docker-container" >> $GITHUB_OUTPUT
35
+ else
36
+ echo "push_needed=false" >> $GITHUB_OUTPUT
37
+ echo "docker_driver=docker" >> $GITHUB_OUTPUT
38
+ fi
28
39
outputs :
29
40
has_changes : ${{ steps.check_diff.outputs.has_changes }}
41
+ push_needed : ${{ steps.check_push.outputs.push_needed }}
42
+ docker_driver : ${{ steps.check_push.outputs.docker_driver }}
30
43
31
44
build :
32
- needs : check-changes
33
- if : ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
34
- runs-on : [ubuntu-latest]
45
+ needs : check-env
46
+ if : ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
47
+ strategy :
48
+ matrix :
49
+ include :
50
+ - platform : linux/amd64
51
+ runner : ubuntu-latest
52
+ suffix : amd64
53
+ - platform : linux/arm64
54
+ runner : github-arm64-2c-8gb
55
+ suffix : arm64
56
+ - platform : linux/arm/v7
57
+ runner : github-arm64-2c-8gb
58
+ suffix : arm
59
+ runs-on : ${{ matrix.runner }}
60
+ env :
61
+ DOCKER_TAG : latest
35
62
steps :
36
63
- uses : actions/checkout@v4
37
64
with :
38
65
show-progress : false
39
- - name : Checking if image needs to be pushed
40
- run : |
41
- if [ "${{ github.repository }}" == "antrea-io/antrea" ] && [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
42
- echo "push_needed=true" >> $GITHUB_ENV
43
- echo "docker_driver=docker-container" >> $GITHUB_ENV
44
- else
45
- echo "push_needed=false" >> $GITHUB_ENV
46
- echo "docker_driver=docker" >> $GITHUB_ENV
47
- fi
48
66
- name : Set up Docker Buildx
49
67
uses : docker/setup-buildx-action@v3
50
68
with :
51
- driver : ${{ env.docker_driver }}
52
- - name : Build Antrea amd64 Docker image without pushing to registry
53
- if : ${{ env.push_needed == 'false' }}
69
+ driver : ${{ needs.check- env.outputs .docker_driver }}
70
+ - name : Build Antrea Docker image without pushing to registry
71
+ if : ${{ needs.check- env.outputs .push_needed == 'false' }}
54
72
run : |
55
- ./hack/build-antrea-linux-all.sh --pull
56
- - name : Build and push Antrea amd64 Docker image to registry
57
- if : ${{ env.push_needed == 'true' }}
73
+ ./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} -- pull
74
+ - name : Build and push Antrea Docker image to registry
75
+ if : ${{ needs.check- env.outputs .push_needed == 'true' }}
58
76
env :
59
77
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
60
78
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
61
79
run : |
62
80
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
63
- ./hack/build-antrea-linux-all.sh --pull --push-base-images
64
- docker tag antrea/antrea-controller-ubuntu:latest antrea/antrea-controller-ubuntu-amd64:latest
65
- docker tag antrea/antrea-agent-ubuntu:latest antrea/antrea-agent-ubuntu-amd64:latest
66
- docker push antrea/antrea-controller-ubuntu-amd64:latest
67
- docker push antrea/antrea-agent-ubuntu-amd64:latest
68
- - name : Trigger Antrea arm builds and multi-arch manifest update
69
- if : ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
70
- uses : benc-uk/workflow-dispatch@v1
81
+ ./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull --push-base-images
82
+ docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
83
+ docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
84
+ docker push antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
85
+ docker push antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
86
+
87
+ push-manifest :
88
+ needs : [check-env, build]
89
+ if : ${{ needs.check-env.outputs.push_needed == 'true' }}
90
+ runs-on : ubuntu-latest
91
+ env :
92
+ DOCKER_TAG : latest
93
+ steps :
94
+ - name : Set up Docker Buildx
95
+ uses : docker/setup-buildx-action@v3
71
96
with :
72
- repo : vmware-tanzu/antrea-build-infra
73
- ref : refs/heads/main
74
- workflow : Build Antrea ARM images and push manifest
75
- token : ${{ secrets.ANTREA_BUILD_INFRA_WORKFLOW_DISPATCH_PAT }}
76
- inputs : ${{ format('{{ "antrea-repository":"antrea-io/antrea", "antrea-ref":"{0}", "docker-tag":"{1}" }}', github.ref, 'latest') }}
97
+ driver : ${{ needs.check-env.outputs.docker_driver }}
98
+ - name : Docker login
99
+ env :
100
+ DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
101
+ DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
102
+ run : |
103
+ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
104
+ - name : Create and push manifest for controller image
105
+ run : |
106
+ docker manifest create antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \
107
+ antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
108
+ antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
109
+ antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
110
+ docker manifest push --purge antrea/antrea-controller-ubuntu:"${DOCKER_TAG}"
111
+ - name : Create and push manifest for agent image
112
+ run : |
113
+ docker manifest create antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \
114
+ antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
115
+ antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
116
+ antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
117
+ docker manifest push --purge antrea/antrea-agent-ubuntu:"${DOCKER_TAG}"
77
118
78
119
build-ubi :
79
- needs : check-changes
80
- if : ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
81
- runs-on : [ubuntu-latest]
120
+ needs : check-env
121
+ if : ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
122
+ runs-on : ubuntu-latest
123
+ env :
124
+ DOCKER_TAG : latest
82
125
steps :
83
126
- name : Free disk space
84
127
# https://github.com/actions/virtual-environments/issues/709
@@ -88,40 +131,31 @@ jobs:
88
131
- uses : actions/checkout@v4
89
132
with :
90
133
show-progress : false
91
- - name : Checking if image needs to be pushed
92
- run : |
93
- if [ "${{ github.repository }}" == "antrea-io/antrea" ] && [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
94
- echo "push_needed=true" >> $GITHUB_ENV
95
- echo "docker_driver=docker-container" >> $GITHUB_ENV
96
- else
97
- echo "push_needed=false" >> $GITHUB_ENV
98
- echo "docker_driver=docker" >> $GITHUB_ENV
99
- fi
100
134
- name : Set up Docker Buildx
101
135
uses : docker/setup-buildx-action@v3
102
136
with :
103
- driver : ${{ env.docker_driver }}
137
+ driver : ${{ needs.check- env.outputs .docker_driver }}
104
138
- uses : actions/setup-go@v5
105
139
with :
106
140
go-version-file : ' go.mod'
107
141
- name : Build Antrea UBI9 Docker image without pushing to registry
108
- if : ${{ env.push_needed == 'false' }}
142
+ if : ${{ needs.check- env.outputs .push_needed == 'false' }}
109
143
run : |
110
144
./hack/build-antrea-linux-all.sh --pull --distro ubi
111
145
- name : Build and push Antrea UBI9 Docker image to registry
112
- if : ${{ env.push_needed == 'true' }}
146
+ if : ${{ needs.check- env.outputs .push_needed == 'true' }}
113
147
env :
114
148
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
115
149
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
116
150
run : |
117
151
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
118
152
./hack/build-antrea-linux-all.sh --pull --push-base-images --distro ubi
119
- docker push antrea/antrea-agent-ubi:latest
120
- docker push antrea/antrea-controller-ubi:latest
153
+ docker push antrea/antrea-agent-ubi:"${DOCKER_TAG}"
154
+ docker push antrea/antrea-controller-ubi:"${DOCKER_TAG}"
121
155
122
156
build-scale :
123
- needs : check-changes
124
- if : ${{ needs.check-changes .outputs.has_changes == 'yes' || github.event_name == 'push' }}
157
+ needs : check-env
158
+ if : ${{ needs.check-env .outputs.has_changes == 'yes' || github.event_name == 'push' }}
125
159
runs-on : [ubuntu-latest]
126
160
steps :
127
161
- uses : actions/checkout@v4
@@ -130,7 +164,7 @@ jobs:
130
164
- name : Build Antrea Agent Simulator Docker image
131
165
run : make build-scale-simulator
132
166
- name : Push Antrea Agent Simulator Docker image to registry
133
- if : ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main ' }}
167
+ if : ${{ needs.check-env.outputs.push_needed == 'true ' }}
134
168
env :
135
169
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
136
170
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
@@ -139,18 +173,18 @@ jobs:
139
173
docker push antrea/antrea-ubuntu-simulator:latest
140
174
141
175
build-windows :
142
- needs : check-changes
143
- if : ${{ needs.check-changes .outputs.has_changes == 'yes' || github.event_name == 'push' }}
176
+ needs : check-env
177
+ if : ${{ needs.check-env .outputs.has_changes == 'yes' || github.event_name == 'push' }}
144
178
runs-on : [ubuntu-latest]
145
179
steps :
146
180
- uses : actions/checkout@v4
147
181
with :
148
182
show-progress : false
149
183
- name : Build Antrea Windows Docker image
150
- if : ${{ github.repository != 'antrea-io/antrea' || github.event_name != 'push' || github.ref != 'refs/heads/main ' }}
184
+ if : ${{ needs.check-env.outputs.push_needed == 'false ' }}
151
185
run : ./hack/build-antrea-windows-all.sh --pull
152
186
- name : Push Antrea Windows Docker image to registry
153
- if : ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main ' }}
187
+ if : ${{ needs.check-env.outputs.push_needed == 'true ' }}
154
188
env :
155
189
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
156
190
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
@@ -160,8 +194,8 @@ jobs:
160
194
shell : bash
161
195
162
196
build-antrea-mc-controller :
163
- needs : check-changes
164
- if : ${{ needs.check-changes .outputs.has_changes == 'yes' || github.event_name == 'push' }}
197
+ needs : check-env
198
+ if : ${{ needs.check-env .outputs.has_changes == 'yes' || github.event_name == 'push' }}
165
199
runs-on : [ubuntu-latest]
166
200
steps :
167
201
- uses : actions/checkout@v4
@@ -170,7 +204,7 @@ jobs:
170
204
- name : Build antrea-mc-controller Docker image
171
205
run : make build-antrea-mc-controller
172
206
- name : Push antrea-mc-controller Docker image to registry
173
- if : ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main ' }}
207
+ if : ${{ needs.check-env.outputs.push_needed == 'true ' }}
174
208
env :
175
209
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
176
210
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
@@ -179,8 +213,8 @@ jobs:
179
213
docker push antrea/antrea-mc-controller:latest
180
214
181
215
build-flow-aggregator :
182
- needs : check-changes
183
- if : ${{ needs.check-changes .outputs.has_changes == 'yes' || github.event_name == 'push' }}
216
+ needs : check-env
217
+ if : ${{ needs.check-env .outputs.has_changes == 'yes' || github.event_name == 'push' }}
184
218
runs-on : [ubuntu-latest]
185
219
steps :
186
220
- uses : actions/checkout@v4
@@ -191,7 +225,7 @@ jobs:
191
225
- name : Check flow-aggregator Docker image
192
226
run : docker run antrea/flow-aggregator --version
193
227
- name : Push flow-aggregator Docker image to registry
194
- if : ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main ' }}
228
+ if : ${{ needs.check-env.outputs.push_needed == 'true ' }}
195
229
env :
196
230
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
197
231
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
@@ -200,8 +234,8 @@ jobs:
200
234
docker push antrea/flow-aggregator:latest
201
235
202
236
build-antrea-migrator :
203
- needs : check-changes
204
- if : ${{ needs.check-changes .outputs.has_changes == 'yes' || github.event_name == 'push' }}
237
+ needs : check-env
238
+ if : ${{ needs.check-env .outputs.has_changes == 'yes' || github.event_name == 'push' }}
205
239
runs-on : [ubuntu-latest]
206
240
steps :
207
241
- uses : actions/checkout@v4
@@ -210,7 +244,7 @@ jobs:
210
244
- name : Build antrea-migrator Docker image
211
245
run : make build-migrator
212
246
- name : Push antrea-migrator Docker image to registry
213
- if : ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main ' }}
247
+ if : ${{ needs.check-env.outputs.push_needed == 'true ' }}
214
248
env :
215
249
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
216
250
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
0 commit comments