diff --git a/internal/source/github_events/json_matcher.go b/internal/source/github_events/json_matcher.go index 53e499fae..955592d5b 100644 --- a/internal/source/github_events/json_matcher.go +++ b/internal/source/github_events/json_matcher.go @@ -3,6 +3,7 @@ package github_events import ( "encoding/json" "fmt" + "regexp" "strings" "github.com/sirupsen/logrus" @@ -27,11 +28,23 @@ func (j *JSONPathMatcher) IsEventMatchingCriteria(obj json.RawMessage, jsonPath, j.log.WithError(err).Errorf("while parsing %s JSONPath", jsonPath) return false } - if value != expValue { - return false + + return j.isEqual(expValue, value) +} + +func (j *JSONPathMatcher) isEqual(exp, got string) bool { + // exact match + if exp == got { + return true } - return true + // regexp + matched, err := regexp.MatchString(exp, got) + if err != nil { + j.log.WithError(err).Errorf("while matching %q with regex %q", got, exp) + return false + } + return matched } func (j *JSONPathMatcher) parseJsonpath(raw []byte, jsonpathStr string) (string, error) { diff --git a/internal/source/github_events/jsonschema.json b/internal/source/github_events/jsonschema.json index ef03e34fd..b0c6b7ba5 100644 --- a/internal/source/github_events/jsonschema.json +++ b/internal/source/github_events/jsonschema.json @@ -221,10 +221,12 @@ }, "jsonPath": { "title": "JSONPath Expression", + "description": "The JSONPath expression to filter based on specific criteria within the event payload.", "type": "string" }, "value": { "title": "Value", + "description": "The regex value to match in the JSONPath result.", "type": "string" }, "notificationTemplate": {