diff --git a/README.md b/README.md
index c8f4171..649d99c 100644
--- a/README.md
+++ b/README.md
@@ -50,10 +50,11 @@ Each pattern value may include [wildcards](https://fishshell.com/docs/current/la
Configure the action using the following inputs:
-| Name | Description | Default |
-|--------------|----------------------------------------|-----------------------|
-| `patterns` | A space-separated list of file patterns to match against when running syntax checks; each pattern may include [wildcards](https://fishshell.com/docs/current/language.html#expand-wildcard) and/or [brace expansions](https://fishshell.com/docs/current/language.html?highlight=brace+expansion#brace-expansion) | `**.fish` |
-| `title` | The title to display in the [job summary](#job-summary); can be used to distinguish multiple summaries generated from a single workflow | `Syntax check results` |
+| Name | Description | Default |
+|---------------|----------------------------------------|-----------------------|
+| `annotations` | The string value `'true'` or `'false'` indicating whether to enable [annotations](#annotations) or not | `true` |
+| `patterns` | A space-separated list of file patterns to match against when running syntax checks; each pattern may include [wildcards](https://fishshell.com/docs/current/language.html#expand-wildcard) and/or [brace expansions](https://fishshell.com/docs/current/language.html?highlight=brace+expansion#brace-expansion) | `**.fish` |
+| `title` | The title to display in the [job summary](#job-summary); can be used to distinguish multiple summaries generated from a single workflow | `Syntax check results` |
## Outputs
@@ -65,11 +66,23 @@ The following outputs are made available to subsequent steps in a workflow:
| `passed` | The number of files that passed syntax checks |
| `failed` | The number of files that failed syntax checks |
+## Annotations
+
+Syntax issues identified by this action are displayed as [annotations](https://github.blog/news-insights/product-news/introducing-check-runs-and-annotations/) on the workflow summary page:
+
+
+
+Annotations are also displayed directly alongside the code in the 'Files changed' tab of pull requests:
+
+
+
+This behaviour can be disabled by setting the `annotations` input to `false`.
+
## Job summary
This action generates a [job summary](https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/) at run-time which can be viewed from the workflow run summary page:
-
+
## Action versions
diff --git a/action.yml b/action.yml
index 899ef5a..2f7c96e 100644
--- a/action.yml
+++ b/action.yml
@@ -4,6 +4,10 @@ branding:
icon: 'check'
color: 'green'
inputs:
+ annotations:
+ description: 'Display annotations for syntax errors in workflow summary and pull request checks'
+ required: false
+ default: 'true'
title:
description: 'Title to display in job summary'
required: false
@@ -28,15 +32,17 @@ runs:
- name: Syntax check fish shell files
id: syntax-check
env:
+ ANNOTATIONS: ${{ inputs.annotations }}
TITLE: ${{ inputs.title }}
PATTERNS: ${{ inputs.patterns }}
run: |
set -gx TERM xterm-256color
- set -l passed 0
- set -l failed 0
-
set title "$TITLE"
+ set annotations "$ANNOTATIONS"
+
+ set passed 0
+ set failed 0
for pattern in (string split --no-empty -- " " $PATTERNS)
set -l escaped (string escape --style=script --no-quoted -- $pattern)
@@ -46,13 +52,20 @@ runs:
for file in $files
echo -n " "
- set output (fish --no-execute $file 2>&1)
+ set -l output (fish --no-execute $file 2>&1)
if test $status -ne 0
set_color red; and echo -n "✖"; and set_color normal
echo " $file"
for line in (string split -- $output)
echo " $line"
end
+
+ if test "$annotations" = "true"
+ string match --regex --groups-only '^(?.+)\s+\(line\s+(?[0-9]+)\):\s+(?.+)' $output
+ set -l title "Syntax issue"
+ echo "::error file=$file,line=$line,title=$title::$message"
+ end
+
set failed (math $failed + 1)
else
set_color green; and echo -n "✔"; and set_color normal
@@ -62,7 +75,7 @@ runs:
end
end
- set -l total (math $passed + $failed)
+ set total (math $passed + $failed)
echo
set_color green; and echo -n "passed: $passed"; and set_color normal
diff --git a/images/annotations-pull-request.png b/images/annotations-pull-request.png
new file mode 100644
index 0000000..2fcd71a
Binary files /dev/null and b/images/annotations-pull-request.png differ
diff --git a/images/annotations-workflow-summary.png b/images/annotations-workflow-summary.png
new file mode 100644
index 0000000..aab3dec
Binary files /dev/null and b/images/annotations-workflow-summary.png differ