Kestrel developer guide blog post

Export GitHub issues to CSV or JSON files

We’ve had a busy few weeks, as we’ve welcomed a lot of plugins to the nest during our launch phase. On the surface, it may seem like a small process to change the owner or author of a plugin from one developer to another, but there’s a lot under the hood that goes on to bring new products into the fold.

One task we always make sure to complete is to capture any issues that have been logged for plugins we’re acquiring — we want to be sure we hit the ground running and have a sense for what problems merchants are running into or what enhancements have been requested.

Much of the time, we’re accepting the transfer of a GitHub repo with the codebase + issues to log these problems or requests. We then move these issues to our own tracker (Shortcut), which can easily import from Jira, but not GitHub issues (despite Shortcut having a really great GitHub integration otherwise).

We can see all open issues across our organization using GitHub search with filters for org, is:issue, and optionally, issue state. But, there’s no way to export these GitHub issues to CSV so that we can bring them into Shortcut to track them.

It had been a while since we had to export GitHub issues to a CSV to manually upload them instead to work around this, so I thought, why not write it down this time and share it with you. 🙂

Install Homebrew + GitHub CLI

I use a Mac, so I leveraged Homebrew + GitHub CLI to make this task pretty simple. If you don’t use Homebrew already, you’ll need to install Homebrew on your machine.

Once you have it, next you can install GitHub CLI if needed:

$ brew install gh

Once installed, you need to authenticate. I find it easiest to login via the web using:

$ gh auth login

You’ll walk through a few prompts to authenticate CLI with your account, and there’s even an option to easily log in via the web app.

Now you’re set up to get the issues you need to export!

Export GitHub issues to CSV or JSON

If you only have a single repo, you may find it easiest to use the issue list commands to get all of the issues in a single repo. However, I have a number of repos in my organization that I want to get issues for, so instead I’ll use the issue search instead.

This way, I can use the owner flag to look for all issues in my organization without scoping to a single repo, and can still use the search operators I already know from GitHub.

I’m going to look for open issues across my org in this example, but you may wish to look for all issues for a full “migration” from GitHub issues. First, we’ll export GitHub issues to a JSON file from my organization, saving them to my desktop in an issues.json file.

$ gh search issues --state open --owner {org} --json author,title,body,createdAt,labels,repository,url --limit {count} > Desktop/issues.json

Don’t forget to replace {org} in my example with your organization! Also note the limit flag — you can set a limit for issues here, depending on how many you want to export. Searching in the web view should give you an idea of how many total issues are in your query.

The json flag lets you select which fields you want to include in your file — the available fields are:

assignees
author
authorAssociation
body
closedAt
commentsCount
createdAt
id
isLocked
isPullRequest
labels
number
repository
state
title
updatedAt
url

Once you’ve saved this file, now you can use the JSON output to take further action (e.g. pushing these issues via API to another tool), or we can export GitHub issues to a CSV file by converting it — here’s an online converter you can use to convert your new JSON file to a CSV.

Now go forth and take your shiny new CSV file full of GitHub issues where ever you’d like to go!

Beka Rice Avatar

About the author…

Join the Flock

Product updates, sales & coupons, Woo tutorials. Zero spam.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *