You can convert GitHub issues into Taskwarrior
tasks using gh
and jq
.
The gh
CLI allows you to list all issues in a repository as JSON. This can include
attributes like title
, url
, and labels
. You can then use jq
to
transform this output into a line based format, extract whatever attributes
you need, and finally add them as tasks with task add
.
The gh issue ls --json title,url
outputs something like this:
[
{
"title": "An Issue",
"url": "https://github.com/user/repo/issues/1"
},
{
"title": "Another Issue",
"url": "https://github.com/user/repo/issues/2"
}
]
Then, jq -c '.[]'
will flatten the array and output an issue per line:
{"title":"An Issue", "url":"https://github.com/user/repo/issues/1"}
{"title":"Another Issue","url":"https://github.com/user/repo/issues/2"}
The final script looks like this:
while read -r issue; do
title=$(jq -r '.title' <<< "$issue")
url=$(jq -r '.url' <<< "$issue")
task add "$title" url:"$url"
done < <(gh issue ls --json title,url | jq -c '.[]')
Here, I’ve added url
as a user-defined-attribute (UDA).
I can then inspect a task with task info <task-id>
to see the URL.
Example output (truncated):
$ task
ID Age Description
1 1min An Issue
2 1min Another Issue
$ task info 1
Name Value
ID 1
Description An Issue
Status Pending
URL https://github.com/user/repo/issues/1
You can also turn issue labels into task tags by adding labels
to the gh issue
invocation, like gh issue ls --json title,url,labels
.