Skip to content

Instantly share code, notes, and snippets.

@fmasuhr
Last active August 29, 2015 14:27
Show Gist options
  • Save fmasuhr/5789c787a8cc6b20ca85 to your computer and use it in GitHub Desktop.
Save fmasuhr/5789c787a8cc6b20ca85 to your computer and use it in GitHub Desktop.
Review Github pull requests assigned to authenticated user
require 'octokit'
TITLE = 'example title'
LABEL = 'ready to merge'
COMMENT = '+B'
client = Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'])
pulls = client.list_issues.select { |issue|
issue.pull_request &&
issue.labels.select { |l| l.name == LABEL }.empty? &&
issue.title == TITLE
}
pulls.each do |pull|
client.add_labels_to_an_issue(pull.repository.full_name, pull.number, [LABEL])
client.add_comment(pull.repository.full_name, pull.number, COMMENT)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment