-
Notifications
You must be signed in to change notification settings - Fork 371
283 lines (272 loc) · 11.4 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: Build and push latest image if needed
on:
pull_request:
branches:
- main
- release-*
- feature/*
push:
branches:
- main
- release-*
- feature/*
- push-antrea-ubuntu-images-to-ghcr.io
jobs:
check-env:
name: Compute outputs for use by other jobs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- name: Check whether tests need to be run based on diff
uses: antrea-io/has-changes@v2
id: check_diff
with:
paths-ignore: docs/* ci/jenkins/* *.md hack/.notableofcontents
- name: Checking if image needs to be pushed
id: check_push
run: |
if [ "${{ github.repository }}" == "antrea-io/antrea" ] && [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/push-antrea-ubuntu-images-to-ghcr.io" ]; then
echo "push_needed=true" >> $GITHUB_OUTPUT
echo "docker_driver=docker-container" >> $GITHUB_OUTPUT
else
echo "push_needed=false" >> $GITHUB_OUTPUT
echo "docker_driver=docker" >> $GITHUB_OUTPUT
fi
outputs:
has_changes: ${{ steps.check_diff.outputs.has_changes }}
push_needed: ${{ steps.check_push.outputs.push_needed }}
docker_driver: ${{ steps.check_push.outputs.docker_driver }}
build:
needs: check-env
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
suffix: amd64
- platform: linux/arm64
runner: github-arm64-2c-8gb
suffix: arm64
- platform: linux/arm/v7
runner: github-arm64-2c-8gb
suffix: arm
runs-on: ${{ matrix.runner }}
env:
DOCKER_TAG: test-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: ${{ needs.check-env.outputs.docker_driver }}
- name: Build Antrea Docker image without pushing to registry
if: ${{ needs.check-env.outputs.push_needed == 'false' }}
run: |
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull
- name: Login to Docker Hub
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Antrea Docker image to registries
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
run: |
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull --push-base-images
for registry in "docker.io" "ghcr.io"; do
docker tag antrea/antrea-controller-ubuntu:latest ${registry}/antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker tag antrea/antrea-agent-ubuntu:latest ${registry}/antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push ${registry}/antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push ${registry}/antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
done
# Same repository workflow dispatch to run conformance tests
- name: Run conformance tests
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
uses: benc-uk/workflow-dispatch@v1
with:
workflow: .github/workflows/conformance.yml
inputs: ${{ format('{{ "antrea-version":"{0}", "antrea-image-distro":"ubuntu", "test-suite":"conformance", "runner":"{1}", "antrea-image-platform":"{2}" }}', github.sha, matrix.runner, matrix.platform) }}
push-manifest:
needs: [check-env, build]
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
strategy:
matrix:
registry: [docker.io, ghcr.io]
runs-on: ubuntu-latest
env:
DOCKER_TAG: test-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: ${{ needs.check-env.outputs.docker_driver }}
- name: Login to Docker Hub
if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'docker.io' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'ghcr.io' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest for controller image
run: |
docker manifest create ${{ matrix.registry }}/antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \
${{ matrix.registry }}/antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
${{ matrix.registry }}/antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
${{ matrix.registry }}/antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge ${{ matrix.registry }}/antrea/antrea-controller-ubuntu:"${DOCKER_TAG}"
- name: Create and push manifest for agent image
run: |
docker manifest create ${{ matrix.registry }}/antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \
${{ matrix.registry }}/antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
${{ matrix.registry }}/antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
${{ matrix.registry }}/antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge ${{ matrix.registry }}/antrea/antrea-agent-ubuntu:"${DOCKER_TAG}"
# build-ubi:
# needs: check-env
# if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
# runs-on: ubuntu-latest
# env:
# DOCKER_TAG: latest
# steps:
# - name: Free disk space
# # https://github.com/actions/virtual-environments/issues/709
# run: |
# sudo apt-get clean
# df -h
# - uses: actions/checkout@v4
# with:
# show-progress: false
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# with:
# driver: ${{ needs.check-env.outputs.docker_driver }}
# - uses: actions/setup-go@v5
# with:
# go-version-file: 'go.mod'
# - name: Build Antrea UBI9 Docker image without pushing to registry
# if: ${{ needs.check-env.outputs.push_needed == 'false' }}
# run: |
# ./hack/build-antrea-linux-all.sh --pull --distro ubi
# - name: Build and push Antrea UBI9 Docker image to registry
# if: ${{ needs.check-env.outputs.push_needed == 'true' }}
# env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# ./hack/build-antrea-linux-all.sh --pull --push-base-images --distro ubi
# docker push antrea/antrea-agent-ubi:"${DOCKER_TAG}"
# docker push antrea/antrea-controller-ubi:"${DOCKER_TAG}"
# build-scale:
# needs: check-env
# if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
# runs-on: [ubuntu-latest]
# steps:
# - uses: actions/checkout@v4
# with:
# show-progress: false
# - name: Build Antrea Agent Simulator Docker image
# run: make build-scale-simulator
# - name: Push Antrea Agent Simulator Docker image to registry
# if: ${{ needs.check-env.outputs.push_needed == 'true' }}
# env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# docker push antrea/antrea-ubuntu-simulator:latest
# build-windows:
# needs: check-env
# if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
# runs-on: [ubuntu-latest]
# steps:
# - uses: actions/checkout@v4
# with:
# show-progress: false
# - name: Build Antrea Windows Docker image
# if: ${{ needs.check-env.outputs.push_needed == 'false' }}
# run: ./hack/build-antrea-windows-all.sh --pull
# - name: Push Antrea Windows Docker image to registry
# if: ${{ needs.check-env.outputs.push_needed == 'true' }}
# env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# ./hack/build-antrea-windows-all.sh --pull --push --push-base-images
# shell: bash
# build-antrea-mc-controller:
# needs: check-env
# if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
# runs-on: [ubuntu-latest]
# steps:
# - uses: actions/checkout@v4
# with:
# show-progress: false
# - name: Build antrea-mc-controller Docker image
# run: make build-antrea-mc-controller
# - name: Push antrea-mc-controller Docker image to registry
# if: ${{ needs.check-env.outputs.push_needed == 'true' }}
# env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# docker push antrea/antrea-mc-controller:latest
# build-flow-aggregator:
# needs: check-env
# if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
# runs-on: [ubuntu-latest]
# steps:
# - uses: actions/checkout@v4
# with:
# show-progress: false
# - name: Build flow-aggregator Docker image
# run: make flow-aggregator-image
# - name: Check flow-aggregator Docker image
# run: docker run antrea/flow-aggregator --version
# - name: Push flow-aggregator Docker image to registry
# if: ${{ needs.check-env.outputs.push_needed == 'true' }}
# env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# docker push antrea/flow-aggregator:latest
# build-antrea-migrator:
# needs: check-env
# if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
# runs-on: [ubuntu-latest]
# steps:
# - uses: actions/checkout@v4
# with:
# show-progress: false
# - name: Build antrea-migrator Docker image
# run: make build-migrator
# - name: Push antrea-migrator Docker image to registry
# if: ${{ needs.check-env.outputs.push_needed == 'true' }}
# env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# docker push antrea/antrea-migrator:latest