Merge branch 'master' into master

This commit is contained in:
Aaron Klaassen 2021-10-01 11:20:56 -05:00 committed by GitHub
commit 73f6fb50a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View file

@ -1,4 +1,4 @@
FROM ruby:2.7-alpine
FROM ruby:3-alpine3.13
LABEL "com.github.actions.name"="Comment on PR"
LABEL "com.github.actions.description"="Leaves a comment on an open PR matching a push event."

View file

@ -9,13 +9,17 @@ inputs:
description: Comment's message
required: true
check_for_duplicate_msg:
description: If false, action doesn't check for duplicate msg.
description: If false, action doesn't check for duplicate message.
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
duplicate_msg_pattern:
description: Optional pattern to use when checking for duplicate message.
required: false
runs:
using: 'docker'
image: 'Dockerfile'
@ -23,3 +27,5 @@ runs:
- ${{ inputs.msg }}
- ${{ inputs.check_for_duplicate_msg }}
- ${{ inputs.delete_prev_regex_msg }}
- ${{ inputs.duplicate_msg_pattern }}

View file

@ -21,6 +21,8 @@ end
message = ARGV[0]
check_duplicate_msg = ARGV[1]
delete_prev_regex_msg = ARGV[2]
duplicate_msg_pattern = ARGV[3]
repo = event["repository"]["full_name"]
if ENV.fetch("GITHUB_EVENT_NAME") == "pull_request"
@ -41,7 +43,11 @@ end
coms = github.issue_comments(repo, pr_number)
if check_duplicate_msg == "true"
duplicate = coms.find { |c| c["body"] == message }
if duplicate_msg_pattern != nil
duplicate = coms.find { |c| (c["body"] =~ (Regexp.new duplicate_msg_pattern)) != nil }
else
duplicate = coms.find { |c| c["body"] == message }
end
if duplicate
puts "The PR already contains this message"