Created
March 28, 2020 06:33
-
-
Save toripiyo/8dfa203d1b480ce602044afe3e12d7f7 to your computer and use it in GitHub Desktop.
sample script to create github issue with octokit gem
This file contains hidden or 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
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}) |
This file contains hidden or 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
{ | |
"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