Skip to content

Instantly share code, notes, and snippets.

@stolarczyk
Last active March 4, 2024 01:26
Show Gist options
  • Save stolarczyk/1f072858d24176824dd8572741083d7d to your computer and use it in GitHub Desktop.
Save stolarczyk/1f072858d24176824dd8572741083d7d to your computer and use it in GitHub Desktop.
Save GitHub issues as TSV

Save GitHub issues as TSV

This script saves GitHub issues in TSV format

Installation

The script has two software dependancies:

  1. GitHub CLI for querying GitHub API
  2. jq for transforming the output of the above to TSV format

There are multiple ways to install these tools. If you're using Homebrew on macOS, it's as simple as running the code snippet below:

brew install jq
brew install gh

Usage

  1. Download the script
  2. Make it executable
chmod +x issues2tsv.sh
  1. Run it in the cloned repository
gh repo clone <organization>/<name>
# cd to the cloned repository
./issues2tsv.sh

Content

The following issue attributes are included in the TSV by default: number, title, assignees, state, url.

These are the available issue attributes, the script can be modified to include any of the following:

  assignees
  author
  body
  closed
  closedAt
  comments
  createdAt
  id
  labels
  milestone
  number
  projectCards
  reactionGroups
  state
  title
  updatedAt
  url

Output

The script outputs a TSV file named issues-<date>.tsv with content formatted like this:

number	title	assignees	state	url
<issue_number> <issue_title> <assigned_users> <issue_state> <issue_url>
<issue_number> <issue_title> <assigned_users> <issue_state> <issue_url>
<issue_number> <issue_title> <assigned_users> <issue_state> <issue_url>
#!/usr/bin/env bash
gh issue list --limit 10000 --state all --json number,title,assignees,state,url | jq -r '["number","title","assignees","state","url"], (.[] | [.number, .title, (.assignees | if .|length==0 then "Unassigned" elif .|length>1 then map(.login)|join(",") else .[].login end) , .state, .url]) | @tsv' > issues-$(date '+%Y-%m-%d').tsv
@BrianSwift-Intel
Copy link

Cool. With current gh 2.37.0 (2023-10-17) on Linux I was able to use the --jq option instead of installing and piping to jq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment