Skip to content

Commit 3b466d2

Browse files
authored
simplify github actions workflows (#2338)
1 parent 8fe8bc5 commit 3b466d2

7 files changed

+195
-216
lines changed

.github/workflows/build-arm64-image.yaml

+6-13
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ on:
1414
- 'docs/**'
1515
- '**.md'
1616

17-
concurrency:
17+
concurrency:
1818
group: "${{ github.workflow }}-${{ github.ref }}"
1919
cancel-in-progress: true
2020

21-
env:
22-
GO_VERSION: '1.20'
23-
2421
jobs:
2522
build:
2623
name: Build arm64
@@ -34,13 +31,11 @@ jobs:
3431

3532
- uses: actions/setup-go@v3
3633
with:
37-
go-version: '${{ env.GO_VERSION }}'
34+
go-version-file: go.mod
3835
check-latest: true
39-
id: go
4036

4137
- name: Export Go full version
42-
run: |
43-
echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"
38+
run: echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"
4439

4540
- name: Go Cache
4641
uses: actions/cache@v3
@@ -49,15 +44,13 @@ jobs:
4944
~/.cache/go-build
5045
~/go/pkg/mod
5146
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-arm64-${{ hashFiles('**/go.sum') }}
52-
restore-keys: |
53-
${{ runner.os }}-${{ env.GO_FULL_VER }}-arm64-
47+
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-arm64-
5448

5549
- name: Build
56-
run: |
57-
make release-arm || make release-arm
50+
run: make release-arm || make release-arm
5851

5952
- name: Push
60-
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
53+
if: github.ref == github.event.repository.default_branch || startsWith(github.ref, 'release-')
6154
env:
6255
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
6356
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/build-dpdk-image.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
make build-dpdk
1515
1616
- name: Push
17-
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
17+
if: github.ref == github.event.repository.default_branch || startsWith(github.ref, 'release-')
1818
env:
1919
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
2020
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/build-kube-ovn-debug.yaml

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Build Debug
22
on: workflow_dispatch
33

4-
env:
5-
GO_VERSION: '1.20'
6-
74
jobs:
85
build-debug:
96
name: Build Debug
@@ -13,13 +10,11 @@ jobs:
1310
- uses: docker/setup-buildx-action@v2
1411
- uses: actions/setup-go@v3
1512
with:
16-
go-version: '${{ env.GO_VERSION }}'
13+
go-version-file: go.mod
1714
check-latest: true
18-
id: go
1915

2016
- name: Build
21-
run: |
22-
make image-debug
17+
run: make image-debug
2318

2419
- name: Push
2520
env:

.github/workflows/build-windows.yaml

+47-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Build Windows
22

33
on:
4+
workflow_dispatch:
5+
release:
46
pull_request:
57
branches:
68
- master
@@ -20,13 +22,52 @@ concurrency:
2022
cancel-in-progress: true
2123

2224
env:
23-
GO_VERSION: '1.20'
2425
GOSEC_VERSION: '2.14.0'
2526

2627
jobs:
28+
filter:
29+
name: Path Filter
30+
runs-on: ubuntu-22.04
31+
outputs:
32+
build-ovs-ovn: ${{ steps.filter.outputs.windows-ovs-ovn }}
33+
build-kube-ovn: ${{ steps.filter.outputs.windows-kube-ovn }}
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-go@v3
37+
with:
38+
go-version-file: go.mod
39+
check-latest: true
40+
41+
- name: Generate path filter
42+
env:
43+
GOOS: windows
44+
run: |
45+
filter=".github/path-filters.yaml"
46+
workflow=$(echo ${{ github.workflow_ref }} | awk -F@ '{print $1}' | sed 's@^${{ github.repository }}/@@')
47+
cat > $filter <<EOF
48+
windows-ovs-ovn:
49+
- $workflow
50+
windows-kube-ovn:
51+
- $workflow
52+
- go.mod
53+
- go.sum
54+
EOF
55+
module=$(grep ^module go.mod | awk '{print $2}')
56+
go list -f '{{ join .Deps "\n" }}' cmd/windows | grep ^$module/ | while read pkg; do
57+
echo "- ${pkg#${module}/}/*" >> $filter
58+
done
59+
60+
- uses: dorny/paths-filter@v2
61+
id: filter
62+
with:
63+
filters: .github/path-filters.yaml
64+
2765
build-ovs-and-ovn:
2866
name: Build OVS and OVN
67+
needs:
68+
- filter
2969
runs-on: windows-2019
70+
if: github.event_name != 'pull_request' || needs.filter.outputs.build-ovs-ovn == 'true'
3071
steps:
3172
- name: Check out PTHREADS4W
3273
run: |
@@ -127,14 +168,16 @@ jobs:
127168

128169
build-kube-ovn:
129170
name: Build Kube-OVN
171+
needs:
172+
- filter
130173
runs-on: windows-2019
174+
if: github.event_name != 'pull_request' || needs.filter.outputs.build-kube-ovn == 'true'
131175
steps:
132176
- uses: actions/checkout@v3
133177
- uses: actions/setup-go@v3
134178
with:
135-
go-version: '${{ env.GO_VERSION }}'
179+
go-version-file: go.mod
136180
check-latest: true
137-
id: go
138181

139182
- name: Export Go full version
140183
run: |
@@ -149,8 +192,7 @@ jobs:
149192
~\AppData\Local\go-build
150193
~\go\pkg\mod
151194
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-${{ hashFiles('**/go.sum') }}
152-
restore-keys: |
153-
${{ runner.os }}-${{ env.GO_FULL_VER }}-
195+
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-
154196

155197
- name: Install gosec
156198
run: |

0 commit comments

Comments
 (0)