Skip to content

Commit aebff4b

Browse files
committed
feat: add option to enable/disable annotations
1 parent 2bff406 commit aebff4b

File tree

5 files changed

+54
-28
lines changed

5 files changed

+54
-28
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ with:
163163
# ...
164164
```
165165

166+
`annotations`: (optional) To enable/disable GitHub Action annotations.
167+
If disabled (`false`), the output format(s) will follow the golangci-lint configuration file and use the same default as golangci-lint (i.e. `colored-line-number`).
168+
https://golangci-lint.run/usage/configuration/#output-configuration
169+
The default value is `true`.
170+
171+
```yml
172+
uses: golangci/golangci-lint-action@v5
173+
with:
174+
annotations: false
175+
# ...
176+
```
177+
166178
`args`: (optional) golangci-lint command line arguments.
167179
Note: By default, the `.golangci.yml` file should be at the root of the repository.
168180
The location of the configuration file can be changed by using `--config=`

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ inputs:
3535
restore existing caches, subject to other options.
3636
default: 'false'
3737
required: false
38+
annotations:
39+
description: "To Enable/disable GitHub Action annotations"
40+
default: 'true'
41+
required: false
3842
args:
3943
description: "golangci-lint command line arguments"
4044
default: ""

dist/post_run/index.js

+12-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/run/index.js

+12-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/run.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,20 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
192192
const userArgsMap = new Map<string, string>(userArgsList)
193193
const userArgNames = new Set<string>(userArgsList.map(([key]) => key))
194194

195-
const formats = (userArgsMap.get("out-format") || "")
196-
.trim()
197-
.split(",")
198-
.filter((f) => f.length > 0)
199-
.filter((f) => !f.startsWith(`github-actions`))
200-
.concat("github-actions")
201-
.join(",")
202-
203-
addedArgs.push(`--out-format=${formats}`)
204-
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim()
195+
const annotations = core.getInput(`annotations`).trim() !== "false"
196+
197+
if (annotations) {
198+
const formats = (userArgsMap.get("out-format") || "")
199+
.trim()
200+
.split(",")
201+
.filter((f) => f.length > 0)
202+
.filter((f) => !f.startsWith(`github-actions`))
203+
.concat("github-actions")
204+
.join(",")
205+
206+
addedArgs.push(`--out-format=${formats}`)
207+
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim()
208+
}
205209

206210
if (isOnlyNewIssues()) {
207211
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {

0 commit comments

Comments
 (0)