Skip to content

Commit

Permalink
working marky marking
Browse files Browse the repository at this point in the history
  • Loading branch information
bdougie committed Sep 10, 2019
1 parent 593295e commit ee5004b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org' do
gem 'marky_markdown'
gem 'marky_markdown', '~> 0.2.0'
end

4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
marky_markdown (0.1.1)
marky_markdown (0.2.0)

PLATFORMS
ruby

DEPENDENCIES
marky_markdown!
marky_markdown (~> 0.2.0)!

BUNDLED WITH
2.0.2
31 changes: 24 additions & 7 deletions action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,36 @@

# Each Action has an event passed to it.
event = JSON.parse(File.read(ENV['GITHUB_EVENT_PATH']))
safeword = "MARKYMARKED"

# Use GITHUB_TOKEN to interact with the GitHub API
client = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
# puts event
puts "-------------------------------------------------"

# Exit Neutral if this is not a newly "opened" issue
exit(78) if event["action"] != "opened"
#
# Grab issue body
body = event["issue"]["body"]

exit(78) if body.include?(safeword)

# Use GITHUB_TOKEN to interact with the GitHub API
client = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])

number = event["issue"]["number"]
full_name = event["repository"]["full_name"]

puts "-------------------------------------------------"
puts MarkyMarkdown::Transformer.transform(body)
body = MarkyMarkdown::Transformer.transform(body)

# TODO: Update marky_markdown to output var object to place in comment
comment = "\r\n\r\n<!-- #{safeword} -->"

# client.update_issue(full_name, number, body)
# puts "-------------------------------------------------"
body << comment

# Update same issue with marked file and comment
client.update_issue(full_name, number, {body: body})

puts "MarkyMarkdown::Transformer succesfully marked body"
puts "-------------------------------------------------"

# puts "Action succesful udated issue body"
puts "Action succesful udated issue body"

0 comments on commit ee5004b

Please sign in to comment.