Skip to content

Commit c5d890e

Browse files
authored
Attempt to generate SBOM and Provenance artifacts (#366)
1 parent a193a71 commit c5d890e

File tree

4 files changed

+89
-25
lines changed

4 files changed

+89
-25
lines changed

.github/workflows/build-test.yaml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,50 @@ jobs:
1919
steps:
2020
- name: Checkout code
2121
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
22+
2223
- name: Setup Golang
2324
uses: actions/setup-go@v5
2425
with:
2526
go-version-file: go.mod
27+
2628
- name: Run golangci-lint
2729
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
2830
with:
2931
version: v2.0.2
3032
args: --timeout 10m --verbose --issues-exit-code=0
3133
only-new-issues: true
3234

35+
code-scan:
36+
name: Code Scan
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Run Trivy vulnerability scanner in repo mode
43+
uses: aquasecurity/[email protected]
44+
continue-on-error: true
45+
with:
46+
scan-type: "fs"
47+
ignore-unfixed: true
48+
exit-code: "1"
49+
format: "sarif"
50+
output: "trivy-results.sarif"
51+
severity: "CRITICAL,HIGH,MEDIUM"
52+
53+
- name: Upload Trivy scan results to GitHub Security tab
54+
uses: github/codeql-action/upload-sarif@v3
55+
with:
56+
sarif_file: "trivy-results.sarif"
57+
3358
govulncheck:
3459
runs-on: ubuntu-latest
3560
name: Run govulncheck
3661
steps:
62+
# We only need to checkout as govuln does the go setup...
63+
- name: Checkout code
64+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
65+
3766
- id: govulncheck
3867
uses: golang/govulncheck-action@v1
3968
with:
@@ -45,8 +74,9 @@ jobs:
4574
runs-on: ubuntu-latest
4675
steps:
4776
- name: Checkout code
48-
uses: actions/checkout@v4 # v3.5.3
49-
- name: Setup Go
77+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
78+
79+
- name: Setup Golang
5080
uses: actions/setup-go@v5
5181
with:
5282
go-version-file: go.mod
@@ -88,31 +118,43 @@ jobs:
88118
steps:
89119
- name: Checkout code
90120
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
121+
91122
- name: Set up QEMU
92123
uses: docker/setup-qemu-action@v3
93124

94125
- name: Set up Docker Buildx
95126
uses: docker/setup-buildx-action@v3
96127
with:
97128
platforms: ${{ matrix.platform }}
129+
driver: docker-container
130+
use: true
98131

99132
- name: Build Images
100133
uses: docker/build-push-action@v6
101134
with:
102135
context: .
103136
platforms: ${{ matrix.platform }}
104-
load: true
105137
push: false
106138
tags: quay.io/jetstack/version-checker:${{github.sha}}
107139
cache-from: type=gha
108140
cache-to: type=gha,mode=max
141+
# https://github.com/docker/buildx/issues/1714
142+
# Whilst trivy says it supports .tar etc, it wouldn't work in gha or locally on my machine.
143+
outputs: |-
144+
type=oci,tar=false,compression=uncompressed,dest=./.oci-image
145+
attests: |-
146+
type=sbom
147+
type=provenance,mode=max
109148
110149
- name: Run Trivy vulnerability scanner
111150
uses: aquasecurity/[email protected]
112151
with:
113-
image-ref: "quay.io/jetstack/version-checker:${{github.sha}}"
152+
input: ./.oci-image
114153
format: "table"
115154
exit-code: "1"
116155
ignore-unfixed: true
117156
vuln-type: "os,library"
118157
severity: "CRITICAL,HIGH"
158+
159+
- name: "Cleanup OCI Image from FS"
160+
run: rm -rf ./.oci-image

.github/workflows/helm-docs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
workflow_call:
55
push:
66
paths:
7-
- '!*.md'
8-
- 'deploy/charts/version-checker/**'
7+
- "!*.md"
8+
- "deploy/charts/version-checker/**"
99
branches:
1010
- main
1111

.github/workflows/helm-test.yaml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Test Helm Chart
22
on:
33
pull_request:
44
paths:
5-
- '!*.md'
6-
- 'deploy/charts/version-checker/**'
5+
- "!*.md"
6+
- "deploy/charts/version-checker/**"
77
branches:
8-
- 'main'
8+
- "main"
99

1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
@@ -14,14 +14,19 @@ concurrency:
1414
jobs:
1515
lint:
1616
permissions:
17-
contents: read # for actions/checkout to fetch code
18-
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
17+
contents: read # for actions/checkout to fetch code
18+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
1919
name: Lint Helm Chart
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout code
2323
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2424

25+
- name: Setup Golang
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version-file: go.mod
29+
2530
- uses: azure/setup-helm@v4
2631

2732
- run: helm lint deploy/charts/version-checker
@@ -33,9 +38,12 @@ jobs:
3338
- name: Checkout code
3439
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3540

36-
- uses: azure/setup-helm@v4
41+
- name: Setup Golang
42+
uses: actions/setup-go@v5
3743
with:
38-
token: ${{ github.token }}
44+
go-version-file: go.mod
45+
46+
- uses: azure/setup-helm@v4
3947

4048
- name: Install helm Plugins
4149
run: |
@@ -57,7 +65,9 @@ jobs:
5765
steps:
5866
- name: Checkout code
5967
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
68+
6069
- name: Install Kyverno CLI
6170
uses: kyverno/[email protected]
62-
- uses: azure/setup-helm@v4
63-
- run: kyverno apply -p https://github.com/kyverno/policies/pod-security/restricted --git-branch main --resource <(helm template deploy/charts/version-checker/)
71+
72+
- run: |-
73+
kyverno apply -p https://github.com/kyverno/policies/pod-security/restricted --git-branch main --resource <(helm template deploy/charts/version-checker/)

.github/workflows/release.yaml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ jobs:
1515
prepare-release:
1616
# Don't push back to a tag!
1717
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
18-
name: Prepair release
18+
name: Prepare release
1919
runs-on: ubuntu-latest
2020
permissions:
2121
pull-requests: write
2222
contents: write
2323
steps:
24-
- uses: actions/checkout@v4
24+
- name: Checkout code
25+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
26+
- name: Setup Golang
27+
uses: actions/setup-go@v5
2528
with:
26-
fetch-depth: 0
29+
go-version-file: go.mod
30+
2731
- uses: bhowell2/[email protected]
2832
id: release_number
2933
with:
@@ -113,10 +117,8 @@ jobs:
113117
helm-release:
114118
runs-on: ubuntu-latest
115119
steps:
116-
# Checkout our Repo
117-
- uses: actions/checkout@v4
118-
with:
119-
path: version-checker
120+
- name: Checkout code
121+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
120122

121123
- name: checkout jetstack-charts
122124
uses: actions/checkout@v4
@@ -134,6 +136,9 @@ jobs:
134136
run: |
135137
helm package version-checker/deploy/charts/version-checker -d jetstack-charts/charts/
136138
139+
- name: Login to Quay.io
140+
run: echo "${{ secrets.QUAY_ROBOT_TOKEN }}" | helm registry login quay.io -u ${{ secrets.QUAY_USERNAME }} --password-stdin
141+
137142
- name: Creating PR
138143
if: startsWith(github.ref, 'refs/tags/')
139144
uses: peter-evans/create-pull-request@v7
@@ -149,10 +154,16 @@ jobs:
149154
base: main
150155
draft: ${{ !startsWith(github.ref, 'refs/tags/') }}
151156

157+
- name: Push to Quay
158+
run: |-
159+
helm push jetstack-charts/charts/version-checker-${{ github.ref_name }}.tgz oci://quay.io/quay.io/jetstack/version-checker/chart
160+
152161
docker-release:
153162
runs-on: ubuntu-latest
154163
steps:
155-
- uses: actions/checkout@v4
164+
- name: Checkout code
165+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
166+
156167
- name: Set up QEMU
157168
uses: docker/setup-qemu-action@v3
158169

@@ -178,15 +189,16 @@ jobs:
178189
tags: quay.io/jetstack/version-checker:${{github.ref_name}}
179190
cache-from: type=gha
180191
cache-to: type=gha,mode=max
192+
attests: |-
193+
type=sbom
194+
type=provenance,mode=max
181195
182196
github-release:
183197
name: Create/Update GitHub Release
184198
permissions:
185199
contents: write
186200
runs-on: ubuntu-latest
187201
steps:
188-
- uses: actions/checkout@v4
189-
190202
- name: Create Release / Change Logs
191203
uses: softprops/action-gh-release@v2
192204
with:

0 commit comments

Comments
 (0)