Skip to content

Commit dd0578b

Browse files
committed
all: provide options to specify action output
This includes the output format and the file to which the output should be saved. Change-Id: Iebbc4ecf38f669de441900c4d1ee3f2b83d1c6a9 Reviewed-on: https://go-review.googlesource.com/c/govulncheck-action/+/588735 Run-TryBot: Zvonimir Pavlinovic <[email protected]> Reviewed-by: Ian Cottrell <[email protected]> Commit-Queue: Zvonimir Pavlinovic <[email protected]> TryBot-Bypass: Zvonimir Pavlinovic <[email protected]>
1 parent 3a32958 commit dd0578b

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,20 @@ work-dir: directory in which to run govulncheck, default '.'
6565
repo-checkout: checkout the repository, default true
6666
check-latest: check for the latest Go version, default false
6767
go-version-file: go.mod or go.work file specifying Go version, default ''
68+
output-format: the format of govulncheck output ('text', 'json', or 'sarif'), default 'text'
69+
output-file: the file to which the output is redirected, default '' (no
70+
redirection)
6871
```
6972
The precedence for inputs `go-version-input`, `go-version-file`, and `check-latest`
7073
specifying Go version is inherited from [actions/setup-go](https://github.com/actions/setup-go).
7174

72-
When a vulnerability is found, an error will be displayed for that
75+
The govulncheck-action follows the exit codes of govulncheck command.
76+
Specifying the output format 'json' or 'sarif' will return success even if
77+
there are some vulnerabilities detected. See
78+
[here](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Exit_codes)
79+
for more information.
80+
81+
When a vulnerability is found with 'text' output format, an error will be displayed for that
7382
[GitHub job](https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow)
7483
with information about the vulnerability and how to fix it. For example:
7584

action.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ inputs:
2727
go-version-file:
2828
description: 'Path to the go.mod or go.work file.'
2929
required: false
30+
output-format:
31+
description: 'The format of the output'
32+
required: false
33+
default: 'text'
34+
output-file:
35+
description: 'The file to which the govulncheck output is saved'
36+
required: false
37+
default: ''
3038
runs:
3139
using: "composite"
3240
steps:
@@ -41,6 +49,11 @@ runs:
4149
- name: Install govulncheck
4250
run: go install golang.org/x/vuln/cmd/govulncheck@latest
4351
shell: bash
44-
- name: Run govulncheck
45-
run: govulncheck -C ${{ inputs.work-dir }} ${{ inputs.go-package }}
52+
- if: inputs.output-file == ''
53+
name: Run govulncheck
54+
run: govulncheck -C ${{ inputs.work-dir }} -format ${{ inputs.output-format }} ${{ inputs.go-package }}
55+
shell: bash
56+
- if: inputs.output-file != ''
57+
name: Run govulncheck and save to file
58+
run: govulncheck -C ${{ inputs.work-dir }} -format ${{ inputs.output-format }} ${{ inputs.go-package }} > ${{ inputs.output-file }}
4659
shell: bash

0 commit comments

Comments
 (0)