Skip to content

Commit 9554adf

Browse files
committed
simplify github actions workflows (#2338)
1 parent b62f472 commit 9554adf

File tree

5 files changed

+106
-89
lines changed

5 files changed

+106
-89
lines changed

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ concurrency:
1919
group: "${{ github.workflow }}-${{ github.ref }}"
2020
cancel-in-progress: true
2121

22-
env:
23-
GO_VERSION: '1.19'
24-
2522
jobs:
2623
build:
2724
name: Build arm64
@@ -30,9 +27,8 @@ jobs:
3027
- uses: actions/checkout@v3
3128
- uses: actions/setup-go@v3
3229
with:
33-
go-version: '${{ env.GO_VERSION }}'
30+
go-version-file: go.mod
3431
check-latest: true
35-
id: go
3632

3733
- name: Set up QEMU
3834
uses: docker/setup-qemu-action@v2
@@ -55,10 +51,10 @@ jobs:
5551
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-arm64-
5652

5753
- name: Build
58-
run: |
59-
make release-arm || make release-arm
54+
run: make release-arm || make release-arm
55+
6056
- name: Push
61-
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
57+
if: github.ref == github.event.repository.default_branch || startsWith(github.ref, 'release-')
6258
env:
6359
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
6460
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

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

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

.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
@@ -21,13 +23,52 @@ concurrency:
2123
cancel-in-progress: true
2224

2325
env:
24-
GO_VERSION: '1.19'
2526
GOSEC_VERSION: '2.14.0'
2627

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

132173
build-kube-ovn:
133174
name: Build Kube-OVN
175+
needs:
176+
- filter
134177
runs-on: windows-2019
178+
if: github.event_name != 'pull_request' || needs.filter.outputs.build-kube-ovn == 'true'
135179
steps:
136180
- uses: actions/checkout@v3
137181
- uses: actions/setup-go@v3
138182
with:
139-
go-version: '${{ env.GO_VERSION }}'
183+
go-version-file: go.mod
140184
check-latest: true
141-
id: go
142185

143186
- name: Export Go full version
144187
run: |
@@ -153,8 +196,7 @@ jobs:
153196
~\AppData\Local\go-build
154197
~\go\pkg\mod
155198
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-${{ hashFiles('**/go.sum') }}
156-
restore-keys: |
157-
${{ runner.os }}-${{ env.GO_FULL_VER }}-
199+
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-
158200

159201
- name: Install gosec
160202
run: |

0 commit comments

Comments
 (0)