https://git.521000.bestmunity/t/delete-issues-programmatically/14255
- Learn GitHub GraphQL API
- Prepare PAT with permissions of target issue like
repo
- Get ids of target issues (recomended:
search
query) - Execute
deleteIssue
mutation to delete target issues
My implemention with actions/github-script
https://github.com/eggplants/ghitter/blob/master/.github/workflows/delete.yml
To get target ids with search
query:
query {
search(
type: ISSUE
last: 100 # take n ids from hit list
query: "..." # example: "author:eggplants repo:eggplants/ghitter"
) {
nodes {
... on Issue {
id # e.g. "I_kwDOGrVx0s5Cuyyr"
number # e.g.: 120
}
}
}
}
It returns:
{
search: {
nodes: [
{id: "I_kwDOGrVx0s5Cuyyr", number: 120},
{...},
]
}
}
To delete the issues:
mutation($issueId: ID!) {
deleteIssue(input: {
clientMutationId: "foobar", # any string, even without this field, will work
issueId: $issueId
}) {
clientMutationId
}
}
It returns:
{
deleteIssue: {
clientMutationId: "foobar"
}
}