-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add entrypoint script and dockerfile (#1)
* add entrypoint script and dockerfile Signed-off-by: Ramiro <[email protected]>
- Loading branch information
1 parent
89b0597
commit 1372ddd
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM ruby:3-slim-buster | ||
RUN gem install octokit | ||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT [ "/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: "Notify PR" | ||
description: "Send a message to the pull request" | ||
inputs: | ||
message: | ||
description: 'The message' | ||
default: 'Your preview environment is ready' | ||
required: true | ||
runs: | ||
using: "docker" | ||
image: "Dockerfile" | ||
args: | ||
- ${{ inputs.message }} | ||
branding: | ||
color: 'green' | ||
icon: book-open |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env ruby | ||
require "octokit" | ||
require "json" | ||
|
||
if !ENV["GITHUB_TOKEN"] | ||
puts "Missing GITHUB_TOKEN" | ||
exit(1) | ||
end | ||
|
||
if ENV["GITHUB_EVENT_NAME"] != "pull_request" | ||
puts "This action only supports pull_request events." | ||
exit(1) | ||
end | ||
|
||
message = ARGV[0] | ||
repo = ENV["GITHUB_REPOSITORY"] | ||
|
||
json = File.read(ENV.fetch("GITHUB_EVENT_PATH")) | ||
event = JSON.parse(json) | ||
pr = event["number"] | ||
|
||
github = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"]) | ||
comments = github.issue_comments(repo, pr) | ||
exists = comments.find { |c| c["body"] == message } | ||
|
||
if exists | ||
puts "Message already exists in the PR" | ||
exit(0) | ||
end | ||
|
||
github.add_comment(repo, pr, message) |