Skip to content

Commit cadba1e

Browse files
rimrulguilhem
authored andcommitted
add filter options
1 parent 48c22f7 commit cadba1e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ Aggregate all items in a single issue
3636

3737
Limit size of issue content
3838

39+
### `titleFilter`
40+
41+
Don't create an issue if the title matches the specified regular expression ([go regular expression syntax](https://github.com/google/re2/wiki/Syntax))
42+
43+
### `contentFilter`
44+
45+
Don't create an issue if the content matches the specified regular expression ([go regular expression syntax](https://github.com/google/re2/wiki/Syntax))
46+
3947
## Outputs
4048

4149
### `issues`

main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"text/template"
1111
"time"
12+
"regexp"
1213

1314
"github.com/google/go-github/v33/github"
1415
"golang.org/x/oauth2"
@@ -30,6 +31,8 @@ const (
3031
prefixInput = "prefix"
3132
aggregateInput = "aggragate"
3233
dryRunInput = "dry-run"
34+
titleFilterInput = "titleFilter"
35+
contentFilterInput = "contentFilter"
3336
)
3437

3538
func main() {
@@ -115,6 +118,24 @@ func main() {
115118
content = item.Description
116119
}
117120

121+
122+
filter := a.GetInput(titleFilterInput)
123+
if filter !="" {
124+
matched, _ := regexp.MatchString(filter, item.Title)
125+
if matched {
126+
a.Debugf("No issue created due to title filter")
127+
continue
128+
}
129+
}
130+
filter = a.GetInput(contentFilterInput)
131+
if filter !="" {
132+
matched, _ := regexp.MatchString(filter, content)
133+
if matched {
134+
a.Debugf("No issue created due to content filter")
135+
continue
136+
}
137+
}
138+
118139
markdown, err := converter.ConvertString(content)
119140
if err != nil {
120141
a.Errorf("Fail to convert HTML to markdown: '%s'", err)

0 commit comments

Comments
 (0)