Skip to content

Commit

Permalink
Merge pull request #12 from direct-actions/dev
Browse files Browse the repository at this point in the history
add key_regex
  • Loading branch information
robzr authored Mar 14, 2024
2 parents 5ff3ead + 1efba8e commit 0827e76
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ inputs:
description: (Optional) Unique & hidden key used to match comment(s) across operations.
required: false
type: string
key_regex:
default: ''
description: (Optional) Key regex used when matching existing comments. When not specified, `key` is used instead.
required: false
type: string
match:
default: last
description: Mode to operate on exiting comments, can be `first`, `last` or `all`.
Expand Down Expand Up @@ -169,6 +174,7 @@ runs:
jq \
--arg author '${{ inputs.author }}' \
--arg key '${{ inputs.key }}' \
--arg key_regex '${{ inputs.key_regex }}' \
--arg match '${{ inputs.match }}' \
--arg regex '${{ inputs.regex }}' \
--arg regex_flags '${{ inputs.regex-flags }}' \
Expand All @@ -179,7 +185,14 @@ runs:
else
.
end |
if $ARGS.named.key? != "" then
if $ARGS.named.key_regex != "" then
select(
.body |
capture("<!--direct-actions/pr-comment:key:(?<key>[^>])*-->") |
.key |
test($ARGS.named.key_regex)
)
elif $ARGS.named.key? != "" then
select(
.body |
startswith("<!--direct-actions/pr-comment:key:\($ARGS.named.key)-->")
Expand Down

0 comments on commit 0827e76

Please sign in to comment.