Skip to content

Commit 8bb647d

Browse files
committed
simplify github actions workflows (kubeovn#2338)
1 parent 8e8417c commit 8bb647d

7 files changed

+171
-189
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.19'
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.19'
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

+48-6
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.19'
24-
GOSEC_VERSION: '2.13.1'
25+
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: |
@@ -130,14 +171,16 @@ jobs:
130171

131172
build-kube-ovn:
132173
name: Build Kube-OVN
174+
needs:
175+
- filter
133176
runs-on: windows-2019
177+
if: github.event_name != 'pull_request' || needs.filter.outputs.build-kube-ovn == 'true'
134178
steps:
135179
- uses: actions/checkout@v3
136180
- uses: actions/setup-go@v3
137181
with:
138-
go-version: '${{ env.GO_VERSION }}'
182+
go-version-file: go.mod
139183
check-latest: true
140-
id: go
141184

142185
- name: Export Go full version
143186
run: |
@@ -152,8 +195,7 @@ jobs:
152195
~\AppData\Local\go-build
153196
~\go\pkg\mod
154197
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-${{ hashFiles('**/go.sum') }}
155-
restore-keys: |
156-
${{ runner.os }}-${{ env.GO_FULL_VER }}-
198+
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-
157199

158200
- name: Install gosec
159201
run: |

0 commit comments

Comments
 (0)