mirror of
https://github.com/unsplash/comment-on-pr.git
synced 2024-09-20 07:36:02 +08:00
Delete messages matching the given regex
This commit is contained in:
parent
85a56be792
commit
3c12d183ca
|
@ -24,5 +24,6 @@ jobs:
|
|||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
msg: "Check out this message!"
|
||||
check_for_duplicate_msg: false # OPTIONAL
|
||||
check_for_duplicate_msg: false # OPTIONAL
|
||||
delete_prev_regex_msg: "[0-9]" # OPTIONAL
|
||||
```
|
||||
|
|
|
@ -12,9 +12,14 @@ inputs:
|
|||
description: If false, action doesn't check for duplicate msg.
|
||||
required: false
|
||||
default: true
|
||||
delete_prev_regex_msg:
|
||||
description: If not empty, all messages matching the given regex will be deleted.
|
||||
required: false
|
||||
default: nil
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.msg }}
|
||||
- ${{ inputs.check_for_duplicate_msg }}
|
||||
- ${{ inputs.delete_prev_regex_msg }}
|
||||
|
|
|
@ -20,6 +20,7 @@ end
|
|||
|
||||
message = ARGV[0]
|
||||
check_duplicate_msg = ARGV[1]
|
||||
delete_prev_regex_msg = ARGV[2]
|
||||
repo = event["repository"]["full_name"]
|
||||
|
||||
if ENV.fetch("GITHUB_EVENT_NAME") == "pull_request"
|
||||
|
@ -48,4 +49,12 @@ if check_duplicate_msg == "true"
|
|||
end
|
||||
end
|
||||
|
||||
if delete_prev_regex_msg != nil
|
||||
coms.each do |n|
|
||||
if n["body"].match(/#{delete_prev_regex_msg}/)
|
||||
github.delete_comment(repo, n["id"], opt = {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
github.add_comment(repo, pr_number, message)
|
||||
|
|
Loading…
Reference in a new issue