Skip to content

Commit b518fdb

Browse files
sean-breenAkshay2191
authored andcommitted
[CI/CD] Add govulncheck to CI (#1416)
* [skip ci] add govulncheck workflow * add vulncheck workflow, call from CI.yml, and allow dispatch * add nightly-scans.yml workflow * checkout * checkout via ref name * fix calling workflow * fix startup failure * Add missing permission for security_events * add check for go version in go.mod * fix setting of output from go version step * use toolchain version * remove go version input ot reusable workflow, no longer needed * remove input field
1 parent 21f48af commit b518fdb

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ jobs:
8282
with:
8383
version: v2.4.0
8484

85+
vulnerability-scan:
86+
name: Vulnerability Scan
87+
uses: ./.github/workflows/vulncheck.yml
88+
permissions:
89+
security-events: write
90+
with:
91+
target-branch: ${{ github.event.pull_request.base.ref || github.ref_name }}
92+
8593
unit-test:
8694
name: Unit Tests
8795
runs-on: ubuntu-22.04
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: nightly-scans.yml
2+
on:
3+
schedule:
4+
- cron: '0 2 * * *' # Runs daily at 2:00 AM UTC
5+
workflow_dispatch:
6+
7+
jobs:
8+
scan-main:
9+
name: Vulnerability Scan - Main
10+
uses: ./.github/workflows/vulncheck.yml
11+
with:
12+
target-branch: 'main'
13+
14+
scan-v2:
15+
name: Vulnerability Scan - dev-v2
16+
uses: ./.github/workflows/vulncheck.yml
17+
with:
18+
target-branch: 'dev-v2'

.github/workflows/vulncheck.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: vulncheck.yaml
2+
on:
3+
workflow_call:
4+
inputs:
5+
target-branch:
6+
description: 'Target branch to run govulncheck against'
7+
type: string
8+
required: false
9+
default: 'main'
10+
workflow_dispatch:
11+
inputs:
12+
target-branch:
13+
description: 'Target branch to run govulncheck against'
14+
required: false
15+
default: 'main'
16+
17+
jobs:
18+
vulncheck:
19+
name: Vulnerability Check
20+
runs-on: ubuntu-22.04
21+
permissions:
22+
security-events: write # for reporting vulnerabilities via code-scanning API
23+
steps:
24+
- name: Checkout Repository
25+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
26+
with:
27+
fetch-depth: 0
28+
ref: ${{ inputs.targetBranch || 'main' }}
29+
30+
- name: Check Go version
31+
id: get-go-version
32+
run: |
33+
echo "Reading from go.mod"
34+
GO_VERSION=$(grep -E "^toolchain " go.mod | awk -F' ' '{print $2}' | tr -d 'go')
35+
echo "Found $GO_VERSION"
36+
echo "go-version="$GO_VERSION"" >> $GITHUB_OUTPUT
37+
38+
- name: Run govulncheck
39+
id: govulncheck
40+
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
41+
with:
42+
go-version-input: ${{ steps.get-go-version.outputs.go-version }}

0 commit comments

Comments
 (0)