Skip to content

Commit

Permalink
simplify github actions workflows (#2338)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Feb 22, 2023
1 parent b62f472 commit 9554adf
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 89 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/build-arm64-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

env:
GO_VERSION: '1.19'

jobs:
build:
name: Build arm64
Expand All @@ -30,9 +27,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '${{ env.GO_VERSION }}'
go-version-file: go.mod
check-latest: true
id: go

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

- name: Build
run: |
make release-arm || make release-arm
run: make release-arm || make release-arm

- name: Push
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
if: github.ref == github.event.repository.default_branch || startsWith(github.ref, 'release-')
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-dpdk-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run: |
make build-dpdk
- name: Push
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
if: github.ref == github.event.repository.default_branch || startsWith(github.ref, 'release-')
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
52 changes: 47 additions & 5 deletions .github/workflows/build-windows.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build Windows

on:
workflow_dispatch:
release:
pull_request:
branches:
- master
Expand All @@ -21,13 +23,52 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: '1.19'
GOSEC_VERSION: '2.14.0'

jobs:
filter:
name: Path Filter
runs-on: ubuntu-22.04
outputs:
build-ovs-ovn: ${{ steps.filter.outputs.windows-ovs-ovn }}
build-kube-ovn: ${{ steps.filter.outputs.windows-kube-ovn }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
check-latest: true

- name: Generate path filter
env:
GOOS: windows
run: |
filter=".github/path-filters.yaml"
workflow=$(echo ${{ github.workflow_ref }} | awk -F@ '{print $1}' | sed 's@^${{ github.repository }}/@@')
cat > $filter <<EOF
windows-ovs-ovn:
- $workflow
windows-kube-ovn:
- $workflow
- go.mod
- go.sum
EOF
module=$(grep ^module go.mod | awk '{print $2}')
go list -f '{{ join .Deps "\n" }}' cmd/windows | grep ^$module/ | while read pkg; do
echo "- ${pkg#${module}/}/*" >> $filter
done
- uses: dorny/paths-filter@v2
id: filter
with:
filters: .github/path-filters.yaml

build-ovs-and-ovn:
name: Build OVS and OVN
needs:
- filter
runs-on: windows-2019
if: github.event_name != 'pull_request' || needs.filter.outputs.build-ovs-ovn == 'true'
steps:
- name: Check out PTHREADS4W
run: |
Expand Down Expand Up @@ -131,14 +172,16 @@ jobs:

build-kube-ovn:
name: Build Kube-OVN
needs:
- filter
runs-on: windows-2019
if: github.event_name != 'pull_request' || needs.filter.outputs.build-kube-ovn == 'true'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '${{ env.GO_VERSION }}'
go-version-file: go.mod
check-latest: true
id: go

- name: Export Go full version
run: |
Expand All @@ -153,8 +196,7 @@ jobs:
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.GO_FULL_VER }}-
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-

- name: Install gosec
run: |
Expand Down

0 comments on commit 9554adf

Please sign in to comment.