Created
April 4, 2024 18:26
-
-
Save arifb/ff7c67cd054d3269aa227d5d4da4b3ed to your computer and use it in GitHub Desktop.
github issues export
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 'http' | |
| require 'csv' | |
| require 'json' | |
| # Replace 'your_username' and 'your_repo' with your GitHub username and repository name | |
| username = 'your_username' | |
| repo = 'your_repo' | |
| token = 'your_github_access_token' # Highly recommended for authenticated requests | |
| # GitHub API URL for fetching issues from a repository | |
| url = "https://api.github.com/repos/#{username}/#{repo}/issues" | |
| # Perform the GET request to the GitHub API | |
| response = HTTP.headers("Authorization" => "token #{token}").get(url) | |
| # Parse the JSON response | |
| issues = JSON.parse(response.body) | |
| # Specify the path to your CSV file | |
| csv_file = 'github_issues.csv' | |
| # Open the CSV file for writing | |
| CSV.open(csv_file, 'wb') do |csv| | |
| # Define the column headers | |
| csv << ['ID', 'Title', 'Body'] | |
| # Iterate over each issue and write its details to the CSV file | |
| issues.each do |issue| | |
| csv << [issue['number'], issue['title'], issue['body']] | |
| end | |
| end | |
| puts "Export completed. Check the #{csv_file} file." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment