Run grep
and report results, along with additional context, as annotations.
This is a shameless copy of Code Climate's grep
engine
(license), implementing the same functionality as a GitHub
Action.
The grep
engine is a low-friction way to introduce automated, timely, and
useful feedback on any piece of incoming code you can target with a regular
expression.
We wanted it as a GitHub Action to gain:
- Performance of running over only the changed files in the PR
- Convenience of annotations appearing in the diff (without a Browser Extension)
Note that if you're considering using this Action over Code Climate, you will lose:
- Markdown support in the annotation content (until GitHub implements it)
- Tracking extant Issues over time and centralizing them with other Code Climate analyses
on:
pull_request:
jobs:
grep:
runs-on: ubuntu-latest
steps:
- uses: freckle/grep-action@v1
with:
patterns: |
- pattern: "\\bword\\b"
syntax: extended
binary-files: without-match
paths:
- "**/*"
paths-ignore:
- "test/**/*"
level: warning
title: A brief title
message: |
A longer message body
-
patterns
: See below. -
only-changed
: Iftrue
(the default), only the files changed in the Pull Request will be considered.NOTE: This action doesn't really work on non-
pull_request
events. -
create-new-check
: Iftrue
, a new Check is created and the annotations are attached to it. Default isfalse
, which means to log the annotations normally. -
failure-threshold
: If any annotations are created at or above this level, the run will fail. Seepatterns[].level
for valid values. Default isfailure
. -
github-token
: override the defaultGITHUB_TOKEN
, if desired.
See ./action.yml
for complete details.
The patterns
input is a String (as all inputs must be) that contains a Yaml
Array of Objects with the following keys:
-
pattern
A
grep
"Basic Regular Expression". See the "Basic vs Extended Regular Expressions" section ofgrep(1)
for more details. Required. -
syntax
The
grep
"Pattern Syntax" to use. This corresponds togrep
's-E
,F
,-G
, or-P
options. One ofextended
,fixed
,basic
, orperl
. Default isbasic
(likegrep
itself). -
binary-files
Controls searching in binary files, corresponding to
grep
's--binary-files=<value>
option. One ofbinary
(search binary files but do not print),without-match
(do not search binary files), ortext
(treat all files as text). Default isbinary
(likegrep
itself). -
paths
List of globs, files matching any will be
grep
ped. Default is everything (["**/*"]
). -
paths-ignore
List of globs, files matching
paths
but that match any of these will not begrep
ped. Default is none ([]
). -
level
The level of the resulting annotation,
notice|warning|failure
. Default isnotice
. -
title
A short title for the annotation resulting from this pattern. Required.
-
message
A longer message for the annotation resulting from this pattern. Default is none.
None.