-
Notifications
You must be signed in to change notification settings - Fork 144
82 lines (79 loc) · 2.72 KB
/
main.yaml
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
name: Build and Test
# This workflow will run on master branch and on any pull requests targeting master
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: test and build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
id: go
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: "fs"
ignore-unfixed: true
format: "template"
template: "@/contrib/sarif.tpl"
output: "trivy-results.sarif"
severity: "HIGH,CRITICAL,MEDIUM"
vuln-type: "os,library"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
- name: Dependencies
env:
GO111MODULE: on
run: |
go install golang.org/x/lint/golint@latest
go install github.com/kisielk/errcheck@latest
go install github.com/golangci/golangci-lint/cmd/[email protected]
curl -L -o operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/v1.0.0/operator-sdk-v1.0.0-x86_64-linux-gnu"
chmod +x operator-sdk
sudo mv operator-sdk /bin/
- name: lint and test
env:
GO111MODULE: on
run: |
export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
go get github.com/VictoriaMetrics/operator/api
make lint
make test
- name: Set output variables
id: vars
run: |
IMAGE_TAG=${GITHUB_SHA:0:7}
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: build binary
env:
GO111MODULE: on
TAG: ${{ steps.vars.outputs.IMAGE_TAG }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
make build
- name: build crosscompile and push to remote registry
env:
TAG: ${{ steps.vars.outputs.IMAGE_TAG }}
run: |
if [ -n '${{secrets.REPO_KEY}}' ]; then
echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin
make publish-via-docker
else
echo "there is no docker secret, just build"
make build-operator-crosscompile
fi