Skip to content

Commit 9bcc589

Browse files
committed
adding github sub-issues and issue types scripts post
1 parent 55997a6 commit 9bcc589

File tree

3 files changed

+266
-0
lines changed

3 files changed

+266
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
---
2+
title: 'GitHub Issues: Scripts for working with Sub-Issues and Issue Types'
3+
author: Josh Johanning
4+
date: 2024-11-15 1:00:00 -0600
5+
description: A collection of scripts for working with sub-issues and issue types in GitHub Issues
6+
categories: [GitHub, Scripts]
7+
tags: [GitHub, GitHub Issues, GitHub Projects]
8+
media_subpath: /assets/screenshots/2024-11-15-github-sub-issues-and-issue-types
9+
image:
10+
path: sub-issues-issue-types-light.png
11+
width: 100%
12+
height: 100%
13+
alt: Sub-Issues and Issue Types in GitHub Issues
14+
---
15+
16+
## Overview
17+
18+
Public previews for [Sub-Issues](https://github.com/orgs/community/discussions/139932) and [Issue Types](https://github.com/orgs/community/discussions/139933) have recently shipped, and they are *awesome*! 🎉 I encourage you to sign your org up for the opt-in public preview [here](https://github.com/features/issues/signup).
19+
20+
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. 🚀
21+
22+
> Check out [@mickeygousset](https://github.com/mickeygousset)'s videos for working with [sub-issues](https://www.youtube.com/watch?v=F42FN6cZmA4) and [issue types](https://www.youtube.com/watch?v=2wVmcuCC1is)! ✨
23+
{: .prompt-info }
24+
25+
## The Scripts
26+
27+
### Sub-Issue Scripts
28+
29+
- [`get-parent-issue-of-issue.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/get-parent-issue-of-issue.sh)
30+
- [`get-sub-issues-of-issue.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/get-sub-issues-of-issue.sh)
31+
- [`get-sub-issues-summary-of-issue.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/get-sub-issues-summary-of-issue.sh)
32+
- [`add-sub-issue-to-issue.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/add-sub-issue-to-issue.sh)
33+
- [`remove-sub-issue-from-issue.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/remove-sub-issue-from-issue.sh)
34+
35+
### Issue Type Scripts
36+
37+
- [`get-issue-type-of-issue.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/get-issue-type-of-issue.sh)
38+
- [`update-issue-issue-type.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/update-issue-issue-type.sh)
39+
- [`remove-issue-issue-type.sh`](https://github.com/joshjohanning/github-misc-scripts/blob/main/gh-cli/remove-issue-issue-type.sh)
40+
41+
## Usage
42+
43+
### Sub-Issue Scripts Usage
44+
45+
#### get-parent-issue-of-issue.sh
46+
47+
Gets the parent issue of the specified issue.
48+
49+
Query:
50+
51+
```sh
52+
./get-parent-issue-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 7
53+
```
54+
{: .nolineno}
55+
56+
Response:
57+
58+
```json
59+
{
60+
"title": "Website enhancements",
61+
"number": 5,
62+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/5",
63+
"id": "I_kwDONO_ztc6eXvAG",
64+
"issueType": "Feature"
65+
}
66+
```
67+
{: .nolineno}
68+
69+
#### get-sub-issues-of-issue.sh
70+
71+
Gets a list of sub-issues for the specified issue.
72+
73+
Query:
74+
75+
```sh
76+
./get-sub-issues-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5
77+
```
78+
{: .nolineno}
79+
80+
Response:
81+
82+
```json
83+
{
84+
"totalCount": 3,
85+
"issues": [
86+
{
87+
"title": "Fix login page",
88+
"number": 6,
89+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/6",
90+
"id": "I_kwDONO_ztc6eXvDa",
91+
"issueType": "User Story"
92+
},
93+
{
94+
"title": "Increase contrast of members page",
95+
"number": 7,
96+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/7",
97+
"id": "I_kwDONO_ztc6eXvGo",
98+
"issueType": null
99+
},
100+
{
101+
"title": "Add logout button",
102+
"number": 8,
103+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/8",
104+
"id": "I_kwDONO_ztc6eXvKm",
105+
"issueType": null
106+
}
107+
]
108+
}
109+
```
110+
{: .nolineno}
111+
112+
#### get-sub-issues-summary-of-issue.sh
113+
114+
Gets the sub-issues summary for the specified issue.
115+
116+
Query:
117+
118+
```sh
119+
./get-sub-issues-summary-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5
120+
```
121+
{: .nolineno}
122+
123+
Response:
124+
125+
```json
126+
{
127+
"total": 3,
128+
"completed": 1,
129+
"percentCompleted": 33
130+
}
131+
```
132+
{: .nolineno}
133+
134+
#### remove-sub-issue-from-issue.sh
135+
136+
Removes the specified sub-issue from the specified parent issue.
137+
138+
Query:
139+
140+
```sh
141+
./remove-sub-issue-from-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5 9
142+
```
143+
{: .nolineno}
144+
145+
Response:
146+
147+
```text
148+
Child issue #9 is a sub-issue of parent issue #5.
149+
{
150+
"data": {
151+
"removeSubIssue": {
152+
"issue": {
153+
"title": "Website enhancements",
154+
"number": 5,
155+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/5",
156+
"id": "I_kwDONO_ztc6eXvAG",
157+
"issueType": {
158+
"name": "Feature"
159+
}
160+
},
161+
"subIssue": {
162+
"title": "task 1",
163+
"number": 9,
164+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/9",
165+
"id": "I_kwDONO_ztc6eXvN3",
166+
"issueType": null
167+
}
168+
}
169+
}
170+
}
171+
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.
172+
```
173+
{: .nolineno}
174+
175+
176+
### Issue Types Scripts Usage
177+
178+
#### get-issue-type-of-issue.sh
179+
180+
Gets the issue type of the specified issue.
181+
182+
Query:
183+
184+
```sh
185+
./get-issue-type-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5
186+
```
187+
{: .nolineno}
188+
189+
Response:
190+
191+
```json
192+
{
193+
"title": "Website enhancements",
194+
"number": 5,
195+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/5",
196+
"id": "I_kwDONO_ztc6eXvAG",
197+
"issueType": "Feature"
198+
}
199+
```
200+
{: .nolineno}
201+
202+
#### update-issue-issue-type.sh
203+
204+
Updates/sets the issue type of the specified issue.
205+
206+
Query:
207+
208+
```sh
209+
./update-issue-issue-type.sh joshjohanning-org migrating-ado-to-gh-issues-v2 6 "user story"
210+
```
211+
{: .nolineno}
212+
213+
Response:
214+
215+
```json
216+
{
217+
"data": {
218+
"updateIssueIssueType": {
219+
"issue": {
220+
"title": "Fix login page",
221+
"number": 6,
222+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/6",
223+
"id": "I_kwDONO_ztc6eXvDa",
224+
"issueType": {
225+
"name": "User Story"
226+
}
227+
}
228+
}
229+
}
230+
}
231+
```
232+
{: .nolineno}
233+
234+
#### remove-issue-issue-type.sh
235+
236+
Removes the issue type from the specified issue.
237+
238+
Query:
239+
240+
```sh
241+
./remove-issue-issue-type.sh joshjohanning-org migrating-ado-to-gh-issues-v2 6
242+
```
243+
{: .nolineno}
244+
245+
Response:
246+
247+
```json
248+
{
249+
"data": {
250+
"updateIssueIssueType": {
251+
"issue": {
252+
"title": "Fix login page",
253+
"number": 6,
254+
"url": "https://github.com/joshjohanning-org/migrating-ado-to-gh-issues-v2/issues/6",
255+
"id": "I_kwDONO_ztc6eXvDa",
256+
"issueType": null
257+
}
258+
}
259+
}
260+
}
261+
```
262+
{: .nolineno}
263+
264+
## Summary
265+
266+
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](https://github.blog/changelog/label/projects/) for new Issues/Projects features!

0 commit comments

Comments
 (0)