GitHub Issues: Scripts for working with Sub-Issues and Issue Types
A collection of scripts for working with sub-issues and issue types in GitHub Issues
Overview
Public previews for Sub-Issues and Issue Types have recently shipped, and they are awesome! 🎉 I encourage you to sign your org up for the opt-in public preview here.
I was looking to do some automation with sub-issues and issue types, and noticed that right now we have to use the GraphQL API to work with them. To run certain queries and mutations, we need the GraphQL IDs of the fields, which if you don’t know GraphQL, can be a bit of a challenge. I created these helper scripts to abstract this process and make automation much easier. 🚀
Check out @mickeygousset’s videos for working with sub-issues and issue types! ✨
The Scripts
Sub-Issue Scripts
get-parent-issue-of-issue.sh
get-sub-issues-of-issue.sh
get-sub-issues-summary-of-issue.sh
add-sub-issue-to-issue.sh
remove-sub-issue-from-issue.sh
Issue Type Scripts
Usage
Sub-Issue Scripts Usage
get-parent-issue-of-issue.sh
Gets the parent issue of the specified issue.
Query:
1
./get-parent-issue-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 7
Response:
1
2
3
4
5
6
7
{
"title": "Website enhancements",
"number": 5,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/5",
"id": "I_kwDONO_ztc6eXvAG",
"issueType": "Feature"
}
get-sub-issues-of-issue.sh
Gets a list of sub-issues for the specified issue.
Query:
1
./get-sub-issues-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
"totalCount": 3,
"issues": [
{
"title": "Fix login page",
"number": 6,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/6",
"id": "I_kwDONO_ztc6eXvDa",
"issueType": "User Story"
},
{
"title": "Increase contrast of members page",
"number": 7,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/7",
"id": "I_kwDONO_ztc6eXvGo",
"issueType": null
},
{
"title": "Add logout button",
"number": 8,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/8",
"id": "I_kwDONO_ztc6eXvKm",
"issueType": null
}
]
}
get-sub-issues-summary-of-issue.sh
Gets the sub-issues summary for the specified issue.
Query:
1
./get-sub-issues-summary-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5
Response:
1
2
3
4
5
{
"total": 3,
"completed": 1,
"percentCompleted": 33
}
remove-sub-issue-from-issue.sh
Removes the specified sub-issue from the specified parent issue.
Query:
1
./remove-sub-issue-from-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5 9
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Child issue #9 is a sub-issue of parent issue #5.
{
"data": {
"removeSubIssue": {
"issue": {
"title": "Website enhancements",
"number": 5,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/5",
"id": "I_kwDONO_ztc6eXvAG",
"issueType": {
"name": "Feature"
}
},
"subIssue": {
"title": "task 1",
"number": 9,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/9",
"id": "I_kwDONO_ztc6eXvN3",
"issueType": null
}
}
}
}
Successfully removed issue joshjohanning-org/migrating-ado-to-gh-issues-v2#9 as a sub-issue to joshjohanning-org/migrating-ado-to-gh-issues-v2#5.
Issue Types Scripts Usage
get-issue-type-of-issue.sh
Gets the issue type of the specified issue.
Query:
1
./get-issue-type-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5
Response:
1
2
3
4
5
6
7
{
"title": "Website enhancements",
"number": 5,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/5",
"id": "I_kwDONO_ztc6eXvAG",
"issueType": "Feature"
}
update-issue-issue-type.sh
Updates/sets the issue type of the specified issue.
Query:
1
./update-issue-issue-type.sh joshjohanning-org migrating-ado-to-gh-issues-v2 6 "user story"
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"data": {
"updateIssueIssueType": {
"issue": {
"title": "Fix login page",
"number": 6,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/6",
"id": "I_kwDONO_ztc6eXvDa",
"issueType": {
"name": "User Story"
}
}
}
}
}
remove-issue-issue-type.sh
Removes the issue type from the specified issue.
Query:
1
./remove-issue-issue-type.sh joshjohanning-org migrating-ado-to-gh-issues-v2 6
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"data": {
"updateIssueIssueType": {
"issue": {
"title": "Fix login page",
"number": 6,
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/6",
"id": "I_kwDONO_ztc6eXvDa",
"issueType": null
}
}
}
}
Summary
Working with GraphQL can sometimes be challenging, especially if you’re more familiar with REST APIs. I hope you find these scripts helpful! Please let me know if you have any questions or feedback. 🚀 Keep an eye on the changelog for new Issues/Projects features!