Skip to content

Instantly share code, notes, and snippets.

@toripiyo
Created March 28, 2020 06:33
Show Gist options
  • Save toripiyo/8dfa203d1b480ce602044afe3e12d7f7 to your computer and use it in GitHub Desktop.
Save toripiyo/8dfa203d1b480ce602044afe3e12d7f7 to your computer and use it in GitHub Desktop.
sample script to create github issue with octokit gem
require 'json'
require 'octokit'
access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client = Octokit::Client.new(:access_token => access_token)
repo = 'toripiyo/xxxxx'
# read json file
json_file_name = 'sample.json'
file = File.open(json_file_name)
json_data = JSON.load(file)
# create title, body, label
title = 'Hello, Ruby'
body = <<~EOF
**#{json_data['message']}**
- status code is #{json_data['status']}
EOF
labels = "Greeting Messsage"
# create github issue
client.create_issue(repo, title, body, {labels: labels})
{
"message": "I received your message.",
"status": 200
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment