-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (99 loc) · 2.91 KB
/
push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
on:
push:
branches:
- "main"
tags:
- "*"
pull_request: {}
release:
types:
- published
name: CI Build & Test
jobs:
review-go:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: check if go.mod and go.sum are tidy
run: make depscheck
- name: check code format
run: make fmtcheck
- name: check code quality
run: make go-lint
review-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: reviewdog/action-hadolint@v1
with:
reporter: github-pr-review
level: info
filter_mode: file
tests:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: run unit tests
run: make test
docker-build:
runs-on: ubuntu-latest
needs:
- review-go
- review-docker
steps:
- uses: actions/checkout@v3
# try to log into our Harbor, but continue without pushing when secrets
# not available (e.g. when PR from a fork or dependabot). Sadly, the
# secrets context is not available in jobs/steps.if but we copy the
# HARBOR_USER secret into the environment and check that instead.
- uses: docker/login-action@v2
id: docker_login
env:
HARBOR_USER: ${{ secrets.HARBOR_USER }}
if: ${{ env.HARBOR_USER != null }}
with:
username: ${{ secrets.HARBOR_USER }}
password: ${{ secrets.HARBOR_SECRET }}
registry: anx-cr.io
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
anx-cr.io/anexia/csi-driver
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build Docker Image
uses: docker/build-push-action@v3
id: docker_build
with:
push: ${{ steps.docker_login.outcome == 'success' }}
build-args: version=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
tags: |
${{ steps.meta.outputs.tags }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.docker_build.outputs.imageid }}
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
trivyignores: .trivyignore