Skip to content

Commit b8acd7f

Browse files
fix(docker-build): fix sarif security-report
1 parent b94b6e1 commit b8acd7f

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

.github/workflows/docker-build.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@ on:
44
workflow_call:
55
inputs:
66
dockerfile:
7-
description: 'Path to Dockerfile'
8-
default: 'Dockerfile'
7+
description: "Path to Dockerfile"
8+
default: "Dockerfile"
99
type: string
1010
image-name:
11-
description: 'Name of Docker Image'
11+
description: "Name of Docker Image"
1212
type: string
1313
required: true
1414
image-tag:
15-
description: 'Tag of Docker Image'
15+
description: "Tag of Docker Image"
1616
type: string
1717
required: true
1818
security-scan:
19-
description: 'Enable Security Scan'
19+
description: "Enable Security Scan"
2020
default: true
2121
type: boolean
2222
security-report:
23-
description: 'Enable Security Report'
24-
default: 'sarif'
23+
description: 'Security Report Mode (`"sarif"` | `"comment"`), ignored if `security-scan: false`'
24+
default: "sarif"
2525
type: string
2626
hadolint:
27-
description: 'Enable Hadolint'
27+
description: "Enable Hadolint"
2828
default: true
2929
type: boolean
3030
push:
31-
description: 'Push Docker Image to Registry'
31+
description: "Push Docker Image to Registry"
3232
default: false
3333
type: boolean
3434
context:
35-
description: 'Path to Docker Build Context'
36-
default: '.'
35+
description: "Path to Docker Build Context"
36+
default: "."
3737
type: string
3838
registry:
39-
description: 'Docker Registry'
40-
default: 'docker.io'
39+
description: "Docker Registry"
40+
default: "docker.io"
4141
type: string
4242
secrets:
4343
username:
@@ -88,12 +88,12 @@ jobs:
8888
uses: aquasecurity/[email protected]
8989
with:
9090
input: vuln-image.tar
91-
format: 'table'
91+
format: ${{ (inputs.security-report == 'sarif' && 'sarif') || 'table' }}
9292
ignore-unfixed: true
93-
vuln-type: 'os,library'
94-
severity: 'CRITICAL,HIGH'
93+
vuln-type: "os,library"
94+
severity: "CRITICAL,HIGH"
9595
hide-progress: true
96-
output: trivy.txt
96+
output: ${{ (inputs.security-report == 'sarif' && 'trivy-results.sarif') || 'trivy.txt' }}
9797

9898
- name: Read Trivy report file
9999
id: read_trivy
@@ -109,8 +109,8 @@ jobs:
109109
uses: peter-evans/find-comment@v3
110110
with:
111111
issue-number: ${{ github.event.pull_request.number }}
112-
comment-author: 'github-actions[bot]'
113-
body-includes: 'Trivy Security Scan Results'
112+
comment-author: "github-actions[bot]"
113+
body-includes: "Trivy Security Scan Results"
114114

115115
- name: Create or update Trivy comment
116116
if: github.event_name == 'pull_request' && inputs.security-scan && inputs.security-report == 'comment'
@@ -134,7 +134,7 @@ jobs:
134134
if: github.event_name == 'pull_request' && inputs.security-scan && inputs.security-report == 'sarif'
135135
uses: github/codeql-action/upload-sarif@v3
136136
with:
137-
sarif_file: 'trivy-results.sarif'
137+
sarif_file: "trivy-results.sarif"
138138

139139
- name: Run Hadolint Dockerfile linter
140140
id: hadolint
@@ -159,8 +159,8 @@ jobs:
159159
uses: peter-evans/find-comment@v3
160160
with:
161161
issue-number: ${{ github.event.pull_request.number }}
162-
comment-author: 'github-actions[bot]'
163-
body-includes: 'Hadolint Dockerfile Lint Results'
162+
comment-author: "github-actions[bot]"
163+
body-includes: "Hadolint Dockerfile Lint Results"
164164

165165
- name: Create or update Hadolint comment
166166
if: ${{ inputs.hadolint && steps.read_hadolint.outputs.report != '' }}

0 commit comments

Comments
 (0)