2022-02-18 01:47:35 +00:00
|
|
|
name: image-build
|
2020-08-05 23:26:31 -07:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2020-11-03 13:56:57 -08:00
|
|
|
- 'main'
|
2022-01-24 12:39:15 +08:00
|
|
|
- 'release*'
|
2020-08-05 23:26:31 -07:00
|
|
|
|
2022-01-24 12:39:15 +08:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
id-token: write
|
2022-01-15 19:57:35 -08:00
|
|
|
|
2022-11-23 18:59:57 +05:30
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-08-05 23:26:31 -07:00
|
|
|
jobs:
|
2021-02-23 04:18:11 +05:30
|
|
|
pre-checks:
|
2020-08-05 23:26:31 -07:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-12-16 01:16:53 +05:30
|
|
|
- name: Checkout
|
2022-12-05 09:43:16 +01:00
|
|
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
- name: Unshallow
|
2020-08-05 23:26:31 -07:00
|
|
|
run: git fetch --prune --unshallow
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
- name: Set up Go
|
2022-12-06 07:49:45 +01:00
|
|
|
uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613 # v3.4.0
|
2020-08-05 23:26:31 -07:00
|
|
|
with:
|
2022-09-25 12:11:28 +02:00
|
|
|
go-version: ~1.18.6
|
2020-08-05 23:26:31 -07:00
|
|
|
|
2020-12-16 01:16:53 +05:30
|
|
|
- name: Cache Go modules
|
2022-12-05 08:58:10 +01:00
|
|
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # pin@v3
|
2020-12-16 01:16:53 +05:30
|
|
|
with:
|
2022-09-01 19:41:48 +02:00
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
2020-12-16 01:16:53 +05:30
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
2021-02-10 01:04:13 +05:30
|
|
|
- name: gofmt check
|
|
|
|
run: |
|
2021-02-23 04:18:11 +05:30
|
|
|
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "The following files were found to be not go formatted:"
|
|
|
|
gofmt -s -l .
|
|
|
|
echo "Please run 'make fmt' to go format the above files."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-02-10 01:04:13 +05:30
|
|
|
|
2021-10-29 11:24:26 +01:00
|
|
|
- name: goimports
|
|
|
|
run: |
|
|
|
|
if [ "$(goimports -l . | wc -l)" -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "The following files were found to have import formatting issues:"
|
|
|
|
goimports -l -l .
|
|
|
|
echo "Please run 'make fmt' to go format the above files."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-16 01:16:53 +05:30
|
|
|
- name: golangci-lint
|
2022-01-13 10:53:05 +05:30
|
|
|
uses: reviewdog/action-golangci-lint@02bcf8c1a9febe8620f1ca523b18dd64f82296db # v1.25.0
|
2020-12-16 01:16:53 +05:30
|
|
|
|
2021-03-11 23:44:46 +05:30
|
|
|
- name: Checking unused pkgs using go mod tidy
|
|
|
|
run: |
|
|
|
|
make unused-package-check
|
|
|
|
|
2021-02-23 04:18:11 +05:30
|
|
|
build-init-kyverno:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: pre-checks
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-12-05 09:43:16 +01:00
|
|
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
2022-12-06 07:49:45 +01:00
|
|
|
uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613 # v3.4.0
|
2021-02-23 04:18:11 +05:30
|
|
|
with:
|
2022-09-25 12:11:28 +02:00
|
|
|
go-version: ~1.18.6
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- name: Cache Go modules
|
2022-12-05 08:58:10 +01:00
|
|
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # pin@v3
|
2021-02-23 04:18:11 +05:30
|
|
|
with:
|
2022-09-01 19:41:48 +02:00
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
2021-02-23 04:18:11 +05:30
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
2022-08-25 14:32:40 -04:00
|
|
|
- name: ko build
|
2022-08-30 17:30:28 +02:00
|
|
|
run: make ko-build-kyvernopre
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
build-kyverno:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: pre-checks
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-12-05 09:43:16 +01:00
|
|
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
2022-12-06 07:49:45 +01:00
|
|
|
uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613 # v3.4.0
|
2021-02-23 04:18:11 +05:30
|
|
|
with:
|
2022-09-25 12:11:28 +02:00
|
|
|
go-version: ~1.18.6
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- name: Cache Go modules
|
2022-12-05 08:58:10 +01:00
|
|
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # pin@v3
|
2021-02-23 04:18:11 +05:30
|
|
|
with:
|
2022-09-01 19:41:48 +02:00
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
2021-02-23 04:18:11 +05:30
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
2022-08-25 14:32:40 -04:00
|
|
|
- name: ko build
|
2022-08-30 17:30:28 +02:00
|
|
|
run: make ko-build-kyverno
|
2021-02-23 04:18:11 +05:30
|
|
|
|
2021-10-05 11:52:06 +05:30
|
|
|
- name: Trivy Scan Image
|
2022-12-06 14:16:13 +00:00
|
|
|
uses: aquasecurity/trivy-action@9ab158e8597f3b310480b9a69402b419bc03dbd5
|
2021-10-29 11:24:26 +01:00
|
|
|
with:
|
2021-11-22 18:27:51 +05:30
|
|
|
scan-type: 'fs'
|
2021-10-05 11:52:06 +05:30
|
|
|
ignore-unfixed: true
|
2022-02-23 08:10:07 +05:30
|
|
|
format: 'sarif'
|
|
|
|
output: 'trivy-results.sarif'
|
2021-10-05 11:52:06 +05:30
|
|
|
severity: 'CRITICAL,HIGH'
|
|
|
|
|
2021-02-23 04:18:11 +05:30
|
|
|
build-kyverno-cli:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: pre-checks
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-12-05 09:43:16 +01:00
|
|
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
2022-12-06 07:49:45 +01:00
|
|
|
uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613 # v3.4.0
|
2021-02-23 04:18:11 +05:30
|
|
|
with:
|
2022-09-25 12:11:28 +02:00
|
|
|
go-version: ~1.18.6
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- name: Cache Go modules
|
2022-12-05 08:58:10 +01:00
|
|
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # pin@v3
|
2021-02-23 04:18:11 +05:30
|
|
|
with:
|
2022-09-01 19:41:48 +02:00
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
2021-02-23 04:18:11 +05:30
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
2022-08-25 14:32:40 -04:00
|
|
|
- name: ko build
|
2022-08-30 17:30:28 +02:00
|
|
|
run: make ko-build-cli
|