Skip to content

Instantly share code, notes, and snippets.

@charlieegan3
Created March 6, 2017 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlieegan3/6e82dbe38525c1e1af8e7f1071f7e649 to your computer and use it in GitHub Desktop.
Save charlieegan3/6e82dbe38525c1e1af8e7f1071f7e649 to your computer and use it in GitHub Desktop.
github issue watcher
# intended for heroku daily scheduler
require "open-uri"
require "json"
require "pushover"
require "pry"
repos = {
"user/repo" => "tag"
}
query = {
state: :open,
since: (Time.now.utc - (60*60*24)).to_s.split(" ").zip(["T", ""]).flatten.join
}
base_url = "https://api.github.com/repos/OWNER/REPO/issues?"
issues = []
repos.each do |repo, label|
url = [base_url.gsub("OWNER/REPO", repo), URI.encode_www_form(query.merge(labels: label))].join
data = JSON.parse open(url).read
issues += data.map do |issue|
[
"<b>" + repo + "</b>",
"<a href=\"#{issue["html_url"]}\">#{issue["title"]}</a>",
issue["labels"].reject { |l| l["name"] == label }
.map { |label| "<font color=\"##{label["color"]}\">#{label["name"]}</font>" }
.join(", "),
((Time.now.utc - Time.parse(issue["created_at"])) / (60*60*24)).round.to_s + " days ago"
]
end
end
message_title = "#{issues.size} issues"
message_body = issues.map { |i| i.join("\n ") }.join("\n\n")
if issues.size > 0
Pushover.notification(message: message_body,
title: message_title,
html: 1,
user: ENV["PUSHOVER_USER"],
token: ENV["PUSHOVER_TOKEN"])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment